/* CSS Variables for Brand Identity */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #34495e;
  --accent-color: #e74c3c;
  --text-color: #333;
  --text-light: #666;
  --bg-color: #fff;
  --bg-gray: #f8f9fa;
  --border-color: #e1e4e8;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --amazon-orange: #FF9900;
  --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 8px;
  --max-width: 1200px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-primary);
  line-height: 1.7;
  color: var(--text-color);
  background-color: var(--bg-color);
  overflow-x: hidden;
}

/* Performance: GPU Acceleration for animations */
.gpu-accelerate {
  transform: translateZ(0);
  will-change: transform;
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.1rem; }

p {
  margin-bottom: 1.5rem;
  color: var(--text-color);
}

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

a:hover {
  color: var(--primary-color);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Header & Navigation */
.header {
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

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

.nav-link {
  color: var(--text-color);
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}

.search-trigger {
  background: var(--bg-gray);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
  transition: var(--transition);
}

.search-trigger:hover {
  border-color: var(--accent-color);
  color: var(--text-color);
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.hamburger {
  width: 24px;
  height: 2px;
  background: var(--primary-color);
  position: relative;
  transition: var(--transition);
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background: var(--primary-color);
  transition: var(--transition);
}

.hamburger::before { top: -8px; }
.hamburger::after { bottom: -8px; }

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.hero-container {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero h1 {
  color: white;
  margin-bottom: 1.5rem;
  font-size: clamp(2.5rem, 6vw, 4rem);
}

.hero-subtitle {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  margin-bottom: 2rem;
  opacity: 0.95;
  font-weight: 400;
}

.hero-cta {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 1rem 2rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  font-size: 1rem;
  line-height: 1;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.btn-primary:hover {
  background: #c0392b;
  border-color: #c0392b;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: white;
  color: var(--primary-color);
  border-color: white;
}

.btn-secondary:hover {
  background: var(--bg-gray);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-amazon {
  background: var(--amazon-orange);
  color: white;
  border-color: var(--amazon-orange);
}

.btn-amazon:hover {
  background: #FF8C00;
  border-color: #FF8C00;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--accent-color);
  border-color: var(--accent-color);
}

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

/* Container & Sections */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  padding: 5rem 0;
}

.section-header {
  text-align: center;
  margin-bottom: 4rem;
}

.section-subtitle {
  color: var(--text-light);
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto;
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 2rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

/* Card Components */
.card {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2rem;
  transition: var(--transition);
  height: 100%;
}

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

.card-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.card-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.card-description {
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.card-link {
  color: var(--accent-color);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.card-link:hover {
  gap: 0.75rem;
}

/* Comparison Tables */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background: var(--bg-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.comparison-table thead {
  background: var(--primary-color);
  color: white;
}

.comparison-table th,
.comparison-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comparison-table tbody tr:hover {
  background: var(--bg-gray);
}

.comparison-table .highlight {
  background: #fff3cd;
  font-weight: 600;
}

/* Badges & Tags */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-best { background: var(--accent-color); color: white; }

/* Article Content */
.article-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.article-header {
  margin-bottom: 3rem;
  text-align: center;
}

.article-meta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 1rem;
}

.article-content h2 {
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

.article-content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
}

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

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

.article-content blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-light);
}

.article-content code {
  background: var(--bg-gray);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.article-content pre {
  background: var(--primary-color);
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 2rem 0;
}

.article-content pre code {
  background: none;
  color: white;
  padding: 0;
}

/* Table of Contents */
.toc {
  background: var(--bg-gray);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.toc-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

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

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

.toc-list a {
  color: var(--text-color);
  display: block;
  padding: 0.25rem 0;
  transition: var(--transition);
}

.toc-list a:hover {
  color: var(--accent-color);
  padding-left: 0.5rem;
}

.toc-list .toc-level-2 { padding-left: 1rem; }
.toc-list .toc-level-3 { padding-left: 2rem; }

/* Sticky TOC for Desktop */
@media (min-width: 1200px) {
  .article-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
  }

  .toc-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
  }
}

/* Feature Boxes */
.feature-box {
  background: linear-gradient(135deg, var(--bg-gray) 0%, white 100%);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-color);
  padding: 2rem;
  border-radius: var(--radius);
  margin: 2rem 0;
}

.feature-box-title {
  color: var(--primary-color);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pros-cons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

.pros,
.cons {
  padding: 1.5rem;
  border-radius: var(--radius);
}

.pros {
  background: #d4edda;
  border-left: 4px solid var(--success-color);
}

.cons {
  background: #f8d7da;
  border-left: 4px solid var(--accent-color);
}

.pros h4,
.cons h4 {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pros ul,
.cons ul {
  list-style: none;
  padding: 0;
}

.pros li,
.cons li {
  padding-left: 1.5rem;
  position: relative;
  margin-bottom: 0.5rem;
}

.pros li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success-color);
  font-weight: bold;
}

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

/* Search Modal */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  padding: 2rem;
  backdrop-filter: blur(5px);
}

.search-modal.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-container {
  background: white;
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-input-wrapper {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.search-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-family: var(--font-primary);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.search-results {
  overflow-y: auto;
  padding: 1rem;
}

.search-result-item {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--bg-gray);
}

.search-result-title {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.search-result-excerpt {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Footer */
.footer {
  background: var(--primary-color);
  color: white;
  padding: 4rem 0 2rem;
  margin-top: 5rem;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-section h4 {
  color: white;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
}

.footer-links a:hover {
  color: white;
  padding-left: 0.5rem;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 2rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 2rem; }
.mt-4 { margin-top: 3rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 2rem; }
.mb-4 { margin-bottom: 3rem; }
.hidden { display: none; }
.visible { display: block; }

/* Responsive Design */
@media (max-width: 768px) {
  .nav-menu {
    position: fixed;
    top: 70px;
    left: -100%;
    width: 100%;
    height: calc(100vh - 70px);
    background: white;
    flex-direction: column;
    padding: 2rem;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
  }

  .nav-menu.active {
    left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .hero {
    padding: 3rem 1rem;
  }

  .section {
    padding: 3rem 0;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .comparison-table {
    font-size: 0.85rem;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 0.5rem;
  }

  .article-container {
    padding: 2rem 1rem;
  }
}

/* Print Styles */
@media print {
  .header,
  .footer,
  .search-trigger,
  .menu-toggle,
  .btn {
    display: none;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  .article-content {
    max-width: 100%;
  }
}

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

:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

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