/* MSiR Blog Post Styles - Educational, Beautiful, Engaging */

/* Import design tokens */
@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');

/* Import shared component styles */
@import url('./_shared/styles/lists.css');
@import url('./_shared/styles/callouts.css');

:root {
  /* Brand Colors */
  --mad-magenta: #ff3e8a;
  --scientific-cyan: #00a9e0;
  --experiment-orange: #ff9b42;
  --laboratory-dark: #2d3142;
  --flash-green: #57cc99;
  --paper-white: #f8f9fa;
  
  /* 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%);
  
  /* Typography */
  --font-heading: 'Montserrat', sans-serif;
  --font-body: 'Source Sans Pro', sans-serif;
  --font-code: 'Source Code Pro', monospace;
  
  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
  --shadow-glow: 0 0 20px rgba(255, 62, 138, 0.3);
}

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

body {
  font-family: var(--font-body);
  color: var(--laboratory-dark);
  background: var(--paper-white);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Main navigation compatibility */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--mad-magenta);
  text-decoration: none;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--laboratory-dark);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
}

.nav-links a.current,
.nav-links a:hover {
  color: var(--scientific-cyan);
}

.nav-links a.current::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--scientific-cyan);
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--gradient-vibrant);
  color: white;
}

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

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--laboratory-dark);
  cursor: pointer;
}

/* Breadcrumb Navigation */
.breadcrumb {
  background: var(--paper-white);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1rem 0;
  margin-top: 80px; /* Account for fixed header */
}

.breadcrumb .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

.breadcrumb-list li {
  position: relative;
}

.breadcrumb-list li:not(:last-child)::after {
  content: '›';
  margin: 0 0.75rem;
  color: #999;
  font-weight: bold;
}

.breadcrumb-list a {
  color: var(--scientific-cyan);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.breadcrumb-list a:hover {
  color: var(--mad-magenta);
}

.breadcrumb-list li[aria-current="page"] {
  color: var(--laboratory-dark);
  font-weight: 600;
}

/* Blog Header */
.blog-header {
  position: relative;
  min-height: 500px;
  background: var(--gradient-vibrant);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.blog-header::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: slide 20s linear infinite;
}

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

.blog-header-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
  max-width: 900px;
  animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.blog-category {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 0.5rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
}

.blog-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: white;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.blog-subtitle {
  font-size: 1.25rem;
  color: rgba(255,255,255,0.9);
  font-weight: 300;
  margin-bottom: 2rem;
}

.blog-meta {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: center;
  color: rgba(255,255,255,0.9);
  font-size: 0.95rem;
}

.author-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--experiment-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}

/* Blog Content */
.blog-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.blog-content {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--laboratory-dark);
}

.blog-content h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2.25rem;
  margin: 3rem 0 1.5rem;
  color: var(--laboratory-dark);
  position: relative;
  padding-left: 1rem;
}

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

.blog-content h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  margin: 2rem 0 1rem;
  color: var(--scientific-cyan);
}

.blog-content p {
  margin-bottom: 1.5rem;
}

.blog-content em {
  color: var(--mad-magenta);
  font-style: italic;
}

.blog-content strong {
  font-weight: 600;
  color: var(--laboratory-dark);
}

/* Science Notes - now imported from shared styles */

/* Lists - now imported from shared styles */

/* Code Blocks */
.code-block {
  background: var(--laboratory-dark);
  color: var(--flash-green);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 2rem 0;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: var(--shadow-lg);
}

/* Inline Demo Styles */
.demo-inline-container {
  margin: 3rem -2rem;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn 0.6s ease;
  transition: transform 0.3s ease;
}

.demo-inline-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.demo-header {
  background: var(--gradient-cool);
  padding: 1.5rem 2rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.demo-number {
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
}

.demo-header h3 {
  margin: 0;
  color: white;
  font-size: 1.25rem;
}

.demo-instruction {
  margin-left: auto;
  font-size: 0.875rem;
  opacity: 0.9;
  font-style: italic;
}

.demo-frame-wrapper {
  position: relative;
  background: var(--paper-white);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--scientific-cyan);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--paper-white);
  border-top-color: var(--scientific-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.demo-inline {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.demo-caption {
  padding: 1rem 2rem;
  background: rgba(0,169,224,0.05);
  color: var(--laboratory-dark);
  font-size: 0.95rem;
  font-style: italic;
  border-top: 1px solid rgba(0,169,224,0.1);
}

/* Modal Demo Styles */
.demo-modal-trigger {
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.3s ease;
}

.demo-modal-trigger:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

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

.demo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
  transition: transform 0.3s ease;
}

.demo-modal-trigger:hover .demo-preview img {
  transform: scale(1.05);
}

.demo-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.demo-play-btn {
  background: var(--mad-magenta);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 50px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.demo-play-btn:hover {
  background: var(--experiment-orange);
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.demo-play-btn .icon {
  font-size: 1.5rem;
}

.demo-description {
  padding: 1.5rem;
}

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

.demo-description p {
  color: #666;
  font-size: 0.95rem;
}

/* Modal Overlay */
.demo-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(45,49,66,0.95);
  z-index: 1000;
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}

.demo-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.demo-modal-content {
  background: white;
  width: 90%;
  max-width: 1200px;
  height: 80vh;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.4s ease;
  position: relative;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.demo-modal-header {
  background: var(--gradient-vibrant);
  padding: 1.5rem 2rem;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.demo-modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
}

.demo-modal-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.demo-modal-close:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

.demo-modal-body {
  height: calc(100% - 80px);
  position: relative;
  background: var(--paper-white);
}

.demo-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Pull Quotes */
.pull-quote {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--scientific-cyan);
  text-align: center;
  margin: 3rem 0;
  padding: 2rem;
  border-top: 2px solid var(--scientific-cyan);
  border-bottom: 2px solid var(--scientific-cyan);
  font-style: italic;
  position: relative;
}

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

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

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

/* Interactive Elements */
.interactive-callout {
  background: var(--gradient-warm);
  color: white;
  padding: 2rem;
  border-radius: 12px;
  margin: 2rem 0;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.interactive-callout::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: pulse 3s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
}

.interactive-callout h3 {
  position: relative;
  color: white;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.interactive-callout p {
  position: relative;
  opacity: 0.95;
}

/* Enhanced Table of Contents Sidebar */
.table-of-contents-enhanced {
  position: fixed;
  top: 120px;
  left: 2rem;
  width: 280px;
  max-height: calc(100vh - 140px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.toc-container {
  padding: 1.5rem;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 2px solid rgba(0, 169, 224, 0.1);
  padding-bottom: 1rem;
}

.toc-header h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--scientific-cyan);
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-icon {
  font-size: 1.2rem;
}

.toc-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--laboratory-dark);
  padding: 0.25rem;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.toc-toggle:hover {
  background: rgba(0, 169, 224, 0.1);
}

.toc-content {
  display: block;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
}

.toc-list li {
  margin-bottom: 0.5rem;
}

.toc-list a {
  display: block;
  color: var(--laboratory-dark);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

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

.toc-list a.active {
  background: rgba(255, 62, 138, 0.1);
  border-left-color: var(--mad-magenta);
  color: var(--mad-magenta);
  font-weight: 600;
}

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

.toc-list ul a {
  font-size: 0.85rem;
  opacity: 0.8;
}

.toc-metadata {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 1rem;
  margin-bottom: 1rem;
}

.toc-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: #666;
}

.meta-icon {
  font-size: 1rem;
}

.toc-progress {
  margin-bottom: 1rem;
}

.progress-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-vibrant);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-percentage {
  font-size: 0.8rem;
  color: #666;
  text-align: right;
  margin-top: 0.25rem;
  font-weight: 600;
}

.toc-tags {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 1rem;
}

.tags-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toc-tag {
  background: rgba(0, 169, 224, 0.1);
  color: var(--scientific-cyan);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Article Container Layout Fixes */
.article-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  padding-left: 320px; /* Make room for TOC */
  position: relative;
}

.article-content {
  max-width: 800px;
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--laboratory-dark);
  margin: 0; /* Remove auto margins to prevent late centering */
}

/* Responsive Design */
@media (max-width: 1200px) {
  .table-of-contents-enhanced {
    display: none;
  }
  
  .article-container {
    padding-left: 2rem; /* Reset padding when TOC is hidden */
  }
}

@media (max-width: 768px) {
  .blog-container {
    padding: 2rem 1rem;
  }
  
  .article-container {
    padding: 1rem;
  }
  
  .article-content {
    font-size: 1rem;
  }
  
  .demo-inline-container {
    margin: 2rem -1rem;
    border-radius: 0;
  }
  
  .demo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .demo-instruction {
    margin-left: 0;
    margin-top: 0.5rem;
  }
  
  .blog-meta {
    flex-direction: column;
    gap: 1rem;
  }
  
  .demo-modal-content {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  
  .pull-quote {
    font-size: 1.25rem;
    padding: 1.5rem;
  }
}

@media (min-width: 1200px) {
  .demo-inline-container {
    margin: 3rem -4rem;
  }
  
  .blog-content {
    font-size: 1.25rem;
  }
}

/* Print Styles */
@media print {
  .demo-inline-container,
  .demo-modal-trigger,
  .interactive-callout {
    display: none;
  }
  
  .blog-header {
    min-height: auto;
    background: none;
    color: var(--laboratory-dark);
  }
  
  .blog-header-content * {
    color: var(--laboratory-dark) !important;
  }
}

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

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

/* Loading States */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}