/* enhancements.css — UX polish layered on top of the original styles.css.
   v7 — animated counters, sticky ToC, refined typography, stagger animations,
   CTA pulse, animated link arrows, section dividers, breadcrumbs.
*/

/* ============================================================
   1. Smooth scroll + better focus
   ============================================================ */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

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

*:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 3px;
  border-radius: 2px;
}
a:focus-visible, button:focus-visible {
  outline-color: #00d4aa;
  box-shadow: 0 0 0 4px rgba(0, 212, 170, 0.15);
}

/* ============================================================
   2. Skip-to-content link
   ============================================================ */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #1a1a2e;
  color: #00d4aa;
  padding: 0.75rem 1rem;
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
  border-bottom-right-radius: 0.5rem;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* ============================================================
   3. Scroll entrance animations + stagger
   ============================================================ */

[data-animate] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}
[data-animate].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Card-grid stagger — children animate with progressive delay */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
[data-stagger].is-visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(2) { transition-delay: 0.10s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(3) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(4) { transition-delay: 0.20s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(5) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(6) { transition-delay: 0.30s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(7) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(8) { transition-delay: 0.40s; opacity: 1; transform: translateY(0); }
[data-stagger].is-visible > *:nth-child(n+9) { transition-delay: 0.45s; opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  [data-animate], [data-stagger] > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ============================================================
   4. Reading progress bar
   ============================================================ */

#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(to right, #00d4aa, #00b894, #f5a623);
  z-index: 60;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ============================================================
   5. Back-to-top button
   ============================================================ */

#back-to-top {
  position: fixed;
  bottom: 5.5rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: #1a1a2e;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background 0.2s ease;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border: 2px solid #00d4aa;
}
#back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
#back-to-top:hover { background: #00d4aa; color: #1a1a2e; }

@media (min-width: 1024px) {
  #back-to-top { bottom: 1.5rem; right: 1.5rem; width: 48px; height: 48px; }
}

/* ============================================================
   6. Floating mobile CTA
   ============================================================ */

#floating-cta {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  z-index: 45;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
#floating-cta.visible { transform: translateY(0); }
#floating-cta a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#floating-cta a:active { transform: scale(0.97); }
#floating-cta .cta-quote { background: #f5a623; color: #1a1a2e; }
#floating-cta .cta-call { background: #00d4aa; color: #ffffff; }

@media (min-width: 1024px) {
  #floating-cta { display: none; }
  body { padding-bottom: 0 !important; }
}
@media (max-width: 1023px) {
  body { padding-bottom: 5rem; }
}

/* ============================================================
   7. Refined typography
   ============================================================ */

body {
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1 {
  letter-spacing: -0.025em;
  font-feature-settings: "kern" 1, "liga" 1, "case" 1;
}
h2, h3 {
  letter-spacing: -0.015em;
}

/* Display heading variant — for hero sections (big, tight) */
.display-h1, h1.display {
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-weight: 700;
}

/* Lead paragraph — for the introductory paragraph after H1 */
.lead, article > p:first-of-type, .prose > p:first-of-type {
  font-size: 1.125rem;
  line-height: 1.7;
}

/* Drop cap on the very first paragraph of long-form articles (>1000 words) */
article.has-drop-cap > p:first-of-type::first-letter {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  float: left;
  margin: 0.25rem 0.5rem 0 0;
  color: #009e82;
  font-family: Georgia, "Times New Roman", serif;
}

/* Prose readability */
article p, .prose p {
  line-height: 1.75;
  margin-bottom: 1.25em;
}
article h2, .prose h2 {
  scroll-margin-top: 6rem;
  margin-top: 2.5rem;
  margin-bottom: 1.25rem;
}
article h3, .prose h3 {
  scroll-margin-top: 6rem;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}
article ul, article ol, .prose ul, .prose ol {
  margin-top: 0.75em;
  margin-bottom: 1.25em;
}
article li, .prose li {
  line-height: 1.7;
  margin-bottom: 0.5em;
}
article a:not(.btn):not([class*="bg-"]):not([class*="rounded"]),
.prose a {
  color: #009e82;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-thickness 0.15s ease;
}
article a:not(.btn):not([class*="bg-"]):not([class*="rounded"]):hover,
.prose a:hover {
  color: #00d4aa;
  text-decoration-thickness: 2px;
}
article strong, .prose strong { color: #1a1a2e; font-weight: 700; }

/* ============================================================
   8. Better details/summary (FAQ accordions)
   ============================================================ */

details > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  position: relative;
  padding-right: 2.5rem;
  transition: color 0.15s ease;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 14px;
  height: 14px;
  background-image: linear-gradient(#00d4aa, #00d4aa), linear-gradient(#00d4aa, #00d4aa);
  background-position: center, center;
  background-size: 14px 2px, 2px 14px;
  background-repeat: no-repeat;
  transform: translateY(-50%);
  transition: transform 0.25s ease, background-size 0.25s ease;
}
details[open] > summary::after {
  background-size: 14px 2px, 0 14px;
  transform: translateY(-50%) rotate(180deg);
}
details {
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
details[open] { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06); }

/* ============================================================
   9. Card hover lift + stat-counter pulse
   ============================================================ */

.card-hover-lift, a.group {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
a.group:hover {
  transform: translateY(-2px);
}

/* Animated counter — pulse subtly when value changes */
.stat-counter {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-counter.counting {
  transform: scale(1.04);
}

/* ============================================================
   10. Hero pattern overlay
   ============================================================ */

.hero-pattern {
  position: relative;
  isolation: isolate;
}
.hero-pattern::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 30%, rgba(0, 212, 170, 0.08) 0%, transparent 35%),
    radial-gradient(circle at 82% 65%, rgba(245, 166, 35, 0.06) 0%, transparent 40%),
    repeating-linear-gradient(
      135deg,
      transparent 0px,
      transparent 80px,
      rgba(255, 255, 255, 0.012) 80px,
      rgba(255, 255, 255, 0.012) 81px
    );
  z-index: -1;
  pointer-events: none;
}

/* ============================================================
   11. Mobile menu animation
   ============================================================ */

#mobile-menu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.32s cubic-bezier(0.4, 0.0, 0.2, 1);
}
#mobile-menu:not(.hidden) {
  max-height: 36rem;
}
#mobile-menu.is-open { max-height: 36rem; }

/* ============================================================
   12. CTA button pulse — subtle attention-getter
   ============================================================ */

@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(245, 166, 35, 0); }
}
.cta-pulse {
  animation: ctaPulse 2.5s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .cta-pulse { animation: none; } }

/* ============================================================
   13. Animated arrow on text links / CTAs
   ============================================================ */

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-weight: 600;
  position: relative;
}
.arrow-link::after {
  content: "→";
  display: inline-block;
  transition: transform 0.2s ease;
  font-weight: 400;
}
.arrow-link:hover::after {
  transform: translateX(3px);
}

/* Auto-arrow on links matching common patterns inside articles */
article a[href]:not([class*="bg-"]):not([class*="rounded"]):not(.no-arrow):not([href^="tel:"]):not([href^="mailto:"])::after {
  /* No global arrow — keep prose links clean. arrow-link is opt-in. */
}

/* ============================================================
   14. Section dividers — gradient hairline between sections
   ============================================================ */

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 212, 170, 0.3) 50%, transparent);
  margin: 0;
  border: 0;
}

/* When two consecutive sections share the same bg, divider helps */
section + section {
  /* no-op; a separate hairline is opt-in via .section-divider */
}

/* ============================================================
   15. Sticky Table of Contents (sidebar on long article pages)
   ============================================================ */

#toc-sidebar {
  position: fixed;
  top: 7rem;
  right: 1rem;
  width: 240px;
  max-height: calc(100vh - 9rem);
  overflow-y: auto;
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  z-index: 30;
  font-size: 0.85rem;
  display: none;
}
#toc-sidebar.visible { display: block; }
#toc-sidebar h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #009e82;
  margin-bottom: 0.75rem;
}
#toc-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#toc-sidebar li {
  margin-bottom: 0.4rem;
  line-height: 1.4;
}
#toc-sidebar li.toc-h3 {
  padding-left: 0.75rem;
  font-size: 0.78rem;
  opacity: 0.85;
}
#toc-sidebar a {
  color: #4b5563;
  text-decoration: none;
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}
#toc-sidebar a:hover {
  color: #00d4aa;
  background: rgba(0, 212, 170, 0.05);
  border-left-color: #00d4aa;
}
#toc-sidebar a.is-active {
  color: #1a1a2e;
  font-weight: 600;
  border-left-color: #00d4aa;
  background: rgba(0, 212, 170, 0.08);
}

/* Show ToC sidebar only on screens that can fit it */
@media (max-width: 1279px) {
  #toc-sidebar { display: none !important; }
}

/* ============================================================
   16. Print styles
   ============================================================ */

@media print {
  header, footer, #floating-cta, #back-to-top, #reading-progress,
  #toc-sidebar, .skip-link, .no-print {
    display: none !important;
  }
  body { color: #000 !important; background: #fff !important; }
  article { max-width: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555; }
}

/* ============================================================
   17. Callouts
   ============================================================ */

.callout {
  border-left: 4px solid #00d4aa;
  background: rgba(0, 212, 170, 0.05);
  padding: 1.25rem 1.5rem;
  border-radius: 0 0.5rem 0.5rem 0;
  margin: 1.5rem 0;
}
.callout-amber {
  border-left-color: #f5a623;
  background: rgba(245, 166, 35, 0.05);
}

/* ============================================================
   18. Breadcrumbs (global)
   ============================================================ */

.breadcrumbs-bar {
  background: #f9fafb;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  padding: 0.6rem 0;
  font-size: 0.85rem;
}
.breadcrumbs-bar .breadcrumbs-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem;
  color: #6b7280;
}
.breadcrumbs-bar a {
  color: #009e82;
  text-decoration: none;
  font-weight: 500;
}
.breadcrumbs-bar a:hover { text-decoration: underline; }
.breadcrumbs-bar .separator {
  margin: 0 0.5rem;
  color: #cbd5e1;
}
.breadcrumbs-bar .current {
  color: #1a1a2e;
  font-weight: 500;
}

/* ============================================================
   19. Tables
   ============================================================ */

article table, .prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
article table th, .prose table th {
  background: #1a1a2e;
  color: #ffffff;
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  border: 1px solid #1a1a2e;
}
article table td, .prose table td {
  padding: 0.75rem 1rem;
  border: 1px solid #e5e7eb;
}
article table tr:nth-child(even) td, .prose table tr:nth-child(even) td {
  background: #f9fafb;
}

/* ============================================================
   20. Tag pills
   ============================================================ */

.tag-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0, 212, 170, 0.1);
  color: #009e82;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

/* ============================================================
   21. ROI Calculator widget
   ============================================================ */

.roi-calculator {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  padding: 2rem;
}
.roi-calculator label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #1a1a2e;
  font-size: 0.95rem;
}
.roi-calculator input[type="range"] {
  width: 100%;
  margin: 0.5rem 0;
  accent-color: #00d4aa;
}
.roi-calculator input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
}
.roi-calculator input[type="number"]:focus {
  outline: none;
  border-color: #00d4aa;
}
.roi-calculator .roi-output {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
  color: #fff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (min-width: 768px) {
  .roi-calculator .roi-output { grid-template-columns: repeat(4, 1fr); }
}
.roi-calculator .roi-output-item {
  text-align: center;
}
.roi-calculator .roi-output-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #00d4aa;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.roi-calculator .roi-output-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 0.25rem;
}

/* ============================================================
   22. Subtle hover effect on every link (default behaviour for inline content)
   ============================================================ */

p a:not([class*="bg-"]) {
  position: relative;
}
