/* ===========================================
   Article Page Styles - Mobile First
   100% Mobile Compatible
   =========================================== */

/* CSS Variables (fallbacks for consistency) */
:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --primary-200: #c7d2fe;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
}

/* Article Page Base */
.article-page {
  background-color: var(--gray-50);
}

.article-main {
  min-height: 100vh;
}

/* ===================================
   Article Hero Section (matches blog.css)
   =================================== */
.article-hero {
  background: linear-gradient(
    135deg,
    var(--gray-50) 0%,
    #eef2ff 50%,
    var(--gray-50) 100%
  );
  padding: calc(64px + 2rem) 1.5rem 3rem;
  position: relative;
  overflow: hidden;
}

.article-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      circle at 30% 20%,
      rgba(99, 102, 241, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 70% 80%,
      rgba(168, 85, 247, 0.06) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.article-hero .hero-container {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.article-hero .hero-content-centered {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

/* ===========================================
   Breadcrumb (inside hero)
   =========================================== */
.article-hero .breadcrumb {
  margin-bottom: 1.5rem;
}

.article-hero .breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.article-hero .breadcrumb-list li {
  display: flex;
  align-items: center;
}

.article-hero .breadcrumb-list li:not(:last-child)::after {
  content: "/";
  margin-left: 0.5rem;
  color: var(--gray-400);
}

.article-hero .breadcrumb-list a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color 0.2s ease;
  padding: 0.25rem 0; /* Touch target */
  min-height: 44px;
  display: flex;
  align-items: center;
}

.article-hero .breadcrumb-list a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

.article-hero .breadcrumb-list li[aria-current="page"] span {
  color: var(--gray-700);
  font-weight: 500;
}

/* ===========================================
   Hero Badge
   =========================================== */
.article-hero .hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary-700);
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.article-hero .hero-badge svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ===========================================
   Hero Title
   =========================================== */
.article-hero .hero-title {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gray-900);
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

@media (min-width: 640px) {
  .article-hero .hero-title {
    font-size: 2.25rem;
  }
}

@media (min-width: 768px) {
  .article-hero .hero-title {
    font-size: 2.75rem;
    line-height: 1.15;
  }
}

@media (min-width: 1024px) {
  .article-hero .hero-title {
    font-size: 3rem;
  }
}

/* ===========================================
   Hero Subtitle (Excerpt)
   =========================================== */
.article-hero .hero-subtitle {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--gray-600);
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

@media (min-width: 768px) {
  .article-hero .hero-subtitle {
    font-size: 1.125rem;
  }
}

/* ===========================================
   Hero Meta (Author + Stats)
   =========================================== */
.article-hero .hero-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .article-hero .hero-meta {
    flex-direction: row;
    justify-content: center;
    gap: 2rem;
  }
}

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

.article-hero .author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.article-hero .author-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 2px;
}

.article-hero .author-name {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.9375rem;
}

.article-hero .author-date {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.article-hero .article-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.article-hero .stat-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.article-hero .stat-item .icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ===========================================
   Article Layout (Container matches equipment.css)
   =========================================== */
.article-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  max-width: 1280px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .article-layout {
    padding: 2rem 1.5rem;
    gap: 2rem;
  }
}

/* Sidebar hidden on mobile by default */
.article-sidebar {
  display: none;
}

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

/* ===========================================
   Mobile Table of Contents
   =========================================== */
.toc-mobile {
  margin-bottom: 1.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.toc-mobile-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem; /* Increased for touch target */
  min-height: 52px; /* Ensure touch target >= 44px */
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.toc-mobile-toggle:hover,
.toc-mobile-toggle:focus {
  background: rgba(99, 102, 241, 0.05);
}

.toc-mobile-toggle:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: -2px;
}

.toc-mobile-toggle .chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.toc-mobile-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.toc-mobile-nav {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--gray-200);
}

.toc-mobile-nav .toc-list {
  margin: 0;
  padding: 0.5rem 0;
  list-style: none;
}

.toc-mobile-nav .toc-link {
  display: block;
  padding: 0.75rem 0; /* 44px+ touch target */
  min-height: 44px;
  color: var(--gray-600);
  font-size: 0.9375rem;
  text-decoration: none;
  border-bottom: 1px solid var(--gray-100);
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.toc-mobile-nav .toc-link:last-child {
  border-bottom: none;
}

.toc-mobile-nav .toc-link:hover,
.toc-mobile-nav .toc-link:focus {
  color: var(--primary-600);
}

/* ===========================================
   Article Body / Prose Styles
   =========================================== */
.article-body {
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--gray-800);
}

@media (min-width: 768px) {
  .article-body {
    font-size: 1.125rem;
  }
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--gray-900);
  scroll-margin-top: calc(65px + 1.5rem);
}

.article-body h2 {
  font-size: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gray-200);
}

@media (min-width: 768px) {
  .article-body h2 {
    font-size: 1.875rem;
  }
}

.article-body h3 {
  font-size: 1.25rem;
}

@media (min-width: 768px) {
  .article-body h3 {
    font-size: 1.5rem;
  }
}

.article-body h4 {
  font-size: 1.125rem;
}

@media (min-width: 768px) {
  .article-body h4 {
    font-size: 1.25rem;
  }
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body a {
  color: var(--primary-600);
  text-decoration: underline;
  text-decoration-color: rgba(99, 102, 241, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
  /* Ensure tap targets for inline links */
}

.article-body a:hover {
  text-decoration-color: var(--primary-600);
}

.article-body strong {
  font-weight: 700;
  color: var(--gray-900);
}

.article-body em {
  font-style: italic;
}

.article-body code {
  font-family: "Monaco", "Consolas", monospace;
  font-size: 0.875em;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
}

/* Blockquotes */
.article-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
  border-left: 4px solid var(--primary-500);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--gray-700);
}

.article-body blockquote p {
  margin: 0;
}

/* Lists */
.article-body ul,
.article-body ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.article-body li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

.article-body ul.article-list {
  list-style: none;
  padding-left: 0;
}

.article-body .article-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.article-body .article-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary-500);
  font-weight: 700;
}

.article-body .check-item,
.article-body .warn-item {
  padding-left: 2rem;
}

.article-body .check-item::before {
  content: none;
}

.article-body .icon-check {
  position: absolute;
  left: 0;
  color: var(--emerald-500, #10b981);
  font-weight: 700;
}

.article-body .icon-warn {
  position: absolute;
  left: 0;
  color: var(--amber-500, #f59e0b);
}

/* Horizontal Rules */
.article-body hr,
.article-divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gray-300), transparent);
  margin: 2rem 0;
}

/* ===========================================
   Article CTA Section
   =========================================== */
.article-cta {
  margin: 2.5rem 0;
}

.cta-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 16px;
  text-align: center;
}

@media (min-width: 640px) {
  .cta-card {
    padding: 2rem;
  }
}

@media (min-width: 768px) {
  .cta-card {
    padding: 2.5rem;
  }
}

.cta-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.cta-icon svg {
  width: 32px;
  height: 32px;
  stroke: white;
}

.cta-card h3 {
  font-size: 1.375rem;
  margin-bottom: 0.5rem;
  color: white;
}

@media (min-width: 768px) {
  .cta-card h3 {
    font-size: 1.5rem;
  }
}

.cta-card p {
  opacity: 0.9;
  margin-bottom: 1rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.cta-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.875rem;
}

.cta-features li {
  opacity: 0.9;
}

.cta-card .btn-primary {
  background: white;
  color: var(--primary-600);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: 9999px;
  text-decoration: none;
  font-size: 1rem;
  min-height: 48px; /* Touch target */
  transition: all 0.2s ease;
}

.cta-card .btn-primary:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}

.cta-note {
  font-size: 0.8125rem;
  opacity: 0.8;
  margin-top: 1rem;
  margin-bottom: 0;
}

/* ===========================================
   Share Section
   =========================================== */
.article-share {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--gray-100);
  border-radius: 12px;
  text-align: center;
}

.article-share h4 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--gray-900);
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-btn {
  width: 48px; /* Touch target */
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.share-btn svg {
  width: 22px;
  height: 22px;
}

.share-linkedin {
  background: #0077b5;
  color: white;
}

.share-linkedin:hover {
  background: #006699;
  transform: translateY(-2px);
}

.share-twitter {
  background: #1da1f2;
  color: white;
}

.share-twitter:hover {
  background: #0d8ecf;
  transform: translateY(-2px);
}

.share-facebook {
  background: #1877f2;
  color: white;
}

.share-facebook:hover {
  background: #166fe5;
  transform: translateY(-2px);
}

.share-copy {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.share-copy:hover {
  background: var(--primary-500);
  color: white;
  border-color: var(--primary-500);
  transform: translateY(-2px);
}

.share-copy.copied {
  background: var(--emerald-500, #10b981);
  color: white;
  border-color: var(--emerald-500, #10b981);
}

/* ===========================================
   Related Articles
   =========================================== */
.related-articles {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gray-200);
}

.related-articles h3 {
  font-family: "Inter", sans-serif;
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--gray-900);
}

.related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.related-card {
  display: block;
  padding: 1.25rem;
  background: white;
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid var(--gray-200);
  min-height: 48px; /* Touch target */
  -webkit-tap-highlight-color: transparent;
}

.related-card:hover,
.related-card:focus {
  border-color: var(--primary-200);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.related-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary-600);
  margin-bottom: 0.5rem;
}

.related-card h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.related-meta {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

/* ===========================================
   Desktop Styles (Tablet+)
   =========================================== */
@media (min-width: 768px) {
  .article-layout {
    padding: 2.5rem 1.5rem;
    gap: 2.5rem;
  }

  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===========================================
   Desktop Styles (Large screens)
   =========================================== */
@media (min-width: 1024px) {
  .article-layout {
    grid-template-columns: 280px 1fr;
    gap: 3rem;
  }

  /* Show desktop sidebar */
  .article-sidebar {
    display: block;
  }

  /* Hide mobile TOC */
  .toc-mobile {
    display: none;
  }

  .related-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===========================================
   Sidebar / Table of Contents (Desktop)
   =========================================== */
.toc-wrapper {
  position: sticky;
  top: calc(65px + 1.5rem);
  max-height: calc(100vh - 65px - 2rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.toc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
}

.toc-nav {
  margin-bottom: 1.5rem;
}

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

.toc-list li {
  margin-bottom: 2px;
}

.toc-link {
  display: block;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--primary-600);
  background: rgba(99, 102, 241, 0.05);
}

.toc-link.active {
  color: var(--primary-600);
  background: rgba(99, 102, 241, 0.1);
  border-left-color: var(--primary-500);
  font-weight: 500;
}

/* Sidebar CTA */
.toc-cta {
  padding: 1rem;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
  border-radius: 12px;
  text-align: center;
}

.toc-cta-text {
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.toc-cta .btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
  min-height: 44px; /* Touch target */
  background: linear-gradient(
    135deg,
    var(--primary-600) 0%,
    var(--primary-700) 100%
  );
  color: white;
  border-radius: 9999px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.toc-cta .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ===========================================
   Print Styles
   =========================================== */
@media print {
  .article-hero,
  .article-sidebar,
  .toc-mobile,
  .article-cta,
  .article-share,
  .related-articles,
  .landing-header,
  .site-footer {
    display: none !important;
  }

  .article-layout {
    display: block;
    padding: 0;
  }

  .article-body {
    font-size: 11pt;
    line-height: 1.6;
  }

  .article-body a {
    text-decoration: none;
    color: inherit;
  }

  .article-body a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
