/**
 * ZMCOR Blog Enhancements Styles
 * Styles for reading time, TOC, progress bar, related articles
 */

/* ===== Reading Time ===== */
.reading-time {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--color-neutral-600, #475467);
  padding: 0.25rem 0.75rem;
  background: var(--color-neutral-100, #f2f4f7);
  border-radius: var(--radius-full, 9999px);
}

.reading-time svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.blog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-neutral-200, #eaecf0);
}

/* ===== Table of Contents ===== */
.table-of-contents {
  background: var(--color-neutral-50, #f9fafb);
  border: 1px solid var(--color-neutral-200, #eaecf0);
  border-radius: var(--radius-xl, 1rem);
  padding: 1.5rem;
  margin: 2rem 0;
}

.toc-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-neutral-700, #344054);
}

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

.toc-item {
  margin-bottom: 0.5rem;
  counter-increment: toc-counter;
}

.toc-item--h3 {
  padding-left: 1.5rem;
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--color-neutral-600, #475467);
  text-decoration: none;
  font-size: 0.9375rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm, 0.375rem);
  transition: all 0.2s ease;
}

.toc-link::before {
  content: counter(toc-counter) ".";
  font-weight: 600;
  color: var(--color-brand-primary, #0066cc);
  min-width: 1.5rem;
}

.toc-link:hover {
  background: var(--color-neutral-100, #f2f4f7);
  color: var(--color-brand-primary, #0066cc);
}

.toc-link--active {
  background: var(--color-brand-primary, #0066cc);
  color: white;
}

.toc-link--active::before {
  color: inherit;
}

/* ===== Reading Progress Bar ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--color-neutral-200, #eaecf0);
  z-index: 9999;
}

.reading-progress__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg,
    var(--color-brand-primary, #0066cc),
    var(--color-brand-secondary, #00c853)
  );
  transition: width 0.1s ease-out;
}

/* ===== Related Articles ===== */
.related-articles {
  padding: 4rem 0;
  background: var(--color-neutral-50, #f9fafb);
  margin-top: 4rem;
}

.related-articles__title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--color-neutral-900, #101828);
}

.related-articles__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.related-article-card {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: white;
  border-radius: var(--radius-xl, 1rem);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.related-article-card__category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-brand-primary, #0066cc);
  margin-bottom: 0.5rem;
}

.related-article-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-neutral-900, #101828);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.related-article-card__meta {
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--color-neutral-600, #475467);
}

/* ===== Code Block Enhancements ===== */
.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
}

.code-copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm, 0.375rem);
  color: var(--color-neutral-400, #98a2b3);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.code-copy-btn.copied {
  background: var(--color-success, #00c853);
  color: white;
  border-color: var(--color-success, #00c853);
}

/* ===== Heading Links ===== */
.heading-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  opacity: 0;
  color: var(--color-neutral-400, #98a2b3);
  transition: opacity 0.2s ease, color 0.2s ease;
}

h2:hover .heading-link,
h3:hover .heading-link {
  opacity: 1;
}

.heading-link:hover {
  color: var(--color-brand-primary, #0066cc);
}

.heading-link.copied {
  color: var(--color-success, #00c853);
}

/* ===== Social Sharing ===== */
.social-share-container {
  margin: 2rem 0;
}

.social-share-container--inline {
  padding: 1rem 1.5rem;
  background: var(--color-neutral-50, #f9fafb);
  border-radius: var(--radius-lg, 0.75rem);
}

.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-neutral-600, #475467);
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-base, 0.5rem);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.share-btn:hover {
  transform: translateY(-2px);
}

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

.share-btn--twitter:hover {
  background: #0d95e8;
}

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

.share-btn--linkedin:hover {
  background: #006399;
}

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

.share-btn--facebook:hover {
  background: #0d6efd;
}

.share-btn--email {
  background: var(--color-neutral-700, #344054);
  color: white;
}

.share-btn--email:hover {
  background: var(--color-neutral-800, #1d2939);
}

.share-btn--copy {
  background: var(--color-neutral-200, #eaecf0);
  color: var(--color-neutral-700, #344054);
}

.share-btn--copy:hover {
  background: var(--color-neutral-300, #d0d5dd);
}

.share-btn--copied {
  background: var(--color-success, #00c853) !important;
  color: white !important;
}

/* Floating Share Bar */
.share-bar-floating {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%) translateX(-100%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
  border-radius: var(--radius-xl, 1rem);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
  z-index: 100;
}

.share-bar-floating--visible {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  visibility: visible;
}

.share-bar-floating .share-btn {
  width: 44px;
  height: 44px;
}

/* ===== Exit Intent Popup ===== */
.exit-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.exit-popup__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.exit-popup--visible .exit-popup__overlay {
  opacity: 1;
}

.exit-popup__container {
  position: relative;
  max-width: 600px;
  width: 100%;
  background: white;
  border-radius: var(--radius-2xl, 1.5rem);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.exit-popup--visible .exit-popup__container {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.exit-popup__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-neutral-100, #f2f4f7);
  border: none;
  border-radius: 50%;
  color: var(--color-neutral-600, #475467);
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 1;
}

.exit-popup__close:hover {
  background: var(--color-neutral-200, #eaecf0);
}

.exit-popup__content {
  display: flex;
  flex-direction: column;
}

.exit-popup__image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.exit-popup__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exit-popup__text {
  padding: 2rem;
  text-align: center;
}

.exit-popup__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-neutral-900, #101828);
  margin-bottom: 0.5rem;
}

.exit-popup__subtitle {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-brand-primary, #0066cc);
  margin-bottom: 0.75rem;
}

.exit-popup__description {
  color: var(--color-neutral-600, #475467);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.exit-popup__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.exit-popup__cta {
  width: 100%;
  max-width: 300px;
}

.exit-popup__dismiss {
  background: none;
  border: none;
  color: var(--color-neutral-500, #667085);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s ease;
}

.exit-popup__dismiss:hover {
  color: var(--color-neutral-700, #344054);
}

.exit-popup__trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--color-neutral-500, #667085);
}

.exit-popup__trust svg {
  color: var(--color-success, #00c853);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .share-bar-floating {
    display: none;
  }

  .table-of-contents {
    padding: 1rem;
  }

  .related-articles__grid {
    grid-template-columns: 1fr;
  }

  .exit-popup__title {
    font-size: 1.5rem;
  }

  .exit-popup__text {
    padding: 1.5rem;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .reading-progress__fill,
  .share-btn,
  .related-article-card,
  .toc-link,
  .exit-popup__overlay,
  .exit-popup__container {
    transition: none;
  }
}
