
/* ============================================================
   MAGIC LAYER v3 — bumps the page from 7-8/10 to 9-10/10
   Approach: keep existing aesthetic, add atmosphere + motion
   ============================================================ */

/* ---------- 1. AURORA BACKGROUND in hero (subtle) ---------- */
.page-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.page-hero::before {
  content: '';
  position: absolute;
  inset: -20% -10%;
  background:
    radial-gradient(circle at 20% 30%, rgba(45, 184, 245, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 80% 60%, rgba(120, 90, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(45, 184, 245, 0.06) 0%, transparent 40%);
  z-index: -2;
  animation: aurora-drift 20s ease-in-out infinite alternate;
  filter: blur(40px);
  pointer-events: none;
}
@keyframes aurora-drift {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.85; }
  50%  { transform: translate(3%, -2%) scale(1.05); opacity: 1; }
  100% { transform: translate(-2%, 2%) scale(0.98); opacity: 0.9; }
}

/* ---------- 2. SUBTLE GRAIN OVERLAY everywhere ---------- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' /%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- 3. LINEAR-STYLE STAGGERED HERO REVEAL ---------- */
@keyframes reveal-up {
  from { transform: translateY(40%); opacity: 0; filter: blur(10px); }
  to   { transform: translateY(0);    opacity: 1; filter: blur(0); }
}
.page-hero .breadcrumb,
.page-hero .page-label,
.page-hero h1,
.page-hero .page-meta,
.page-hero .tldr-block,
.page-hero .section-intro,
.page-hero .hero-cta-row {
  animation: reveal-up 0.9s cubic-bezier(0.19, 1, 0.22, 1) both;
}
.page-hero .breadcrumb     { animation-delay: 0.00s; }
.page-hero .page-label     { animation-delay: 0.08s; }
.page-hero h1              { animation-delay: 0.16s; }
.page-hero .page-meta      { animation-delay: 0.28s; }
.page-hero .tldr-block     { animation-delay: 0.40s; }
.page-hero .section-intro  { animation-delay: 0.52s; }
.page-hero .hero-cta-row   { animation-delay: 0.64s; }

/* ---------- 4. SCROLL-REVEAL for sections ---------- */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1),
              transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: opacity, transform;
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- 5. SECTION NUMBERS — animate on scroll ---------- */
.section-number {
  background: linear-gradient(180deg,
    rgba(45, 184, 245, 0.35) 0%,
    rgba(45, 184, 245, 0.08) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  transition: background 0.6s ease;
}
.numbered-section:hover .section-number {
  background: linear-gradient(180deg,
    rgba(45, 184, 245, 0.5) 0%,
    rgba(45, 184, 245, 0.15) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* ---------- 6. CARDS — glass + magnetic hover ---------- */
.card, .step-card, .ms-card {
  position: relative;
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    transform 0.4s cubic-bezier(0.19, 1, 0.22, 1),
    border-color 0.3s ease,
    background 0.3s ease,
    box-shadow 0.4s ease;
  /* overflow: hidden removed — was clipping absolute-positioned badges like "Most Popular" */
}
.card::before, .step-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--mx, 50%) var(--my, 50%),
    rgba(45, 184, 245, 0.08),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.card:hover, .step-card:hover, .ms-card:hover {
  transform: translateY(-4px);
  border-color: rgba(45, 184, 245, 0.4);
  background: rgba(255, 255, 255, 0.04);
  box-shadow:
    0 10px 40px -10px rgba(45, 184, 245, 0.15),
    0 0 0 1px rgba(45, 184, 245, 0.1) inset;
}
.card:hover::before, .step-card:hover::before {
  opacity: 1;
}

/* ---------- 7. PRIMARY BUTTON — magnetic glow ---------- */
.btn-primary {
  position: relative;
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.19, 1, 0.22, 1),
    box-shadow 0.3s ease;
  box-shadow:
    0 4px 20px -4px rgba(45, 184, 245, 0.5),
    0 0 0 1px rgba(45, 184, 245, 0.2) inset;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 8px 30px -4px rgba(45, 184, 245, 0.7),
    0 0 0 1px rgba(45, 184, 245, 0.4) inset;
}
.btn-primary:hover::before {
  transform: translateX(100%);
}

/* ---------- 8. STICKY CTA BAR (appears on scroll) ---------- */
.sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: rgba(8, 14, 22, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(45, 184, 245, 0.2);
  padding: 0.875rem 1.5rem;
  transform: translateY(110%);
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  pointer-events: none;
}
.sticky-cta.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}
.sticky-cta-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.sticky-cta-text {
  font-size: 0.92rem;
  color: var(--gray-light, #c8d0d8);
  font-weight: 500;
}
.sticky-cta-text strong { color: var(--white); }
.sticky-cta-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.sticky-cta-actions .btn-primary {
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
}
.sticky-cta-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--gray, #8b9298);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 1rem;
  line-height: 1;
}
.sticky-cta-close:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--white);
}
@media (max-width: 640px) {
  .sticky-cta { padding: 0.75rem 1rem; }
  .sticky-cta-text { font-size: 0.82rem; flex: 1 1 100%; text-align: center; }
  .sticky-cta-actions { flex: 1 1 100%; justify-content: center; }
}

/* ---------- 9. ANIMATED COUNTERS ---------- */
.counter-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--cyan) 0%, #1a8fc7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- 10. TABLE — row hover with cyan accent ---------- */
.comparison-table tbody tr {
  transition: background 0.2s ease, transform 0.2s ease;
}
.comparison-table tbody tr:hover {
  background: rgba(45, 184, 245, 0.05);
  box-shadow: inset 3px 0 0 var(--cyan);
}

/* ---------- 11. FAQ — smooth expand with rotating + ---------- */
.faq-q .faq-toggle {
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  display: inline-block;
}
.faq-q[aria-expanded="true"] .faq-toggle {
  transform: rotate(45deg);
}
.faq-a {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
.faq-item.is-open .faq-a {
  max-height: 1000px;
}

/* ---------- 13. Smooth selection ---------- */
::selection {
  background: rgba(45, 184, 245, 0.4);
  color: var(--white);
}

/* ---------- 14. Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .page-hero::before { animation: none; }
  .reveal-on-scroll { opacity: 1; transform: none; }
}


/* ============================================================
   MOBILE FIXES v3.1
   ============================================================ */

/* ---------- 1. STICKY CTA — fix на мобільному ---------- */
@media (max-width: 768px) {
  .sticky-cta {
    padding: 0.7rem 1rem 0.7rem;
  }
  .sticky-cta-inner {
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
  }
  .sticky-cta-text {
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.4;
    padding-right: 2rem; /* місце для close button */
    position: relative;
  }
  .sticky-cta-actions {
    width: 100%;
    justify-content: stretch;
  }
  .sticky-cta-actions .btn-primary {
    flex: 1;
    text-align: center;
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
  }
  /* Close button у правому верхньому куті блоку, не в кінці */
  .sticky-cta-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    z-index: 10;
  }
  /* Прибираємо close button з actions на мобільному, бо ми його репозиціювали в text */
}

/* ---------- 2. COMPARISON CARDS GRID — stack on mobile ---------- */
@media (max-width: 768px) {
  /* Грід-картки які мали 2 колонки → 1 колонка на мобільному */
  .cards-grid[style*="grid-template-columns:1fr 1fr"],
  .cards-grid[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- 3. COMPARISON TABLE — горизонтальний скрол на мобільному ---------- */
.comparison-table-wrap {
  /* Не змінюємо desktop — без обгортки */
  overflow: visible;
}
@media (max-width: 768px) {
  /* Обгортаємо таблицю в скрольний контейнер на мобільному */
  .comparison-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 0.82rem;
    /* Тінь, що натякає на можливість скролу */
    background:
      linear-gradient(to right, rgba(8,14,22,1) 30%, rgba(8,14,22,0)),
      linear-gradient(to right, rgba(8,14,22,0), rgba(8,14,22,1) 70%) 0 100%,
      radial-gradient(farthest-side at 0% 50%, rgba(45,184,245,0.15), rgba(0,0,0,0)),
      radial-gradient(farthest-side at 100% 50%, rgba(45,184,245,0.15), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: rgba(255, 255, 255, 0.02);
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .comparison-table thead,
  .comparison-table tbody,
  .comparison-table tr {
    display: table;
    width: max-content;
    min-width: 100%;
  }
  .comparison-table th,
  .comparison-table td {
    white-space: normal;
    min-width: 140px;
    padding: 0.75rem 0.85rem;
    vertical-align: top;
  }
  /* Перший стовпець не повинен переноситися (це назва рядка) */
  .comparison-table td:first-child,
  .comparison-table th:first-child {
    white-space: nowrap;
    min-width: auto;
    position: sticky;
    left: 0;
    background: var(--bg2, #0d1620);
    z-index: 1;
  }
  /* Прозорі фони для решти, щоб sticky-перший стовпець не зливався */
  .comparison-table tbody tr:hover td:first-child {
    background: rgba(13, 22, 32, 0.95);
  }
}

/* ---------- 4. SCROLL-REVEAL FALLBACK — JS not loaded або failed ---------- */
/* Якщо JS не запустився, секції не повинні залишатися invisible */
/* Через 3 секунди після завантаження сторінки — все стає видимим */
@keyframes safety-reveal {
  to { opacity: 1; transform: translateY(0); }
}
.reveal-on-scroll {
  /* Безпечний fallback — якщо IntersectionObserver не спрацював за 3s, показуємо */
  animation: safety-reveal 0s ease 3s forwards;
}
/* IS-visible overrides animation і показує одразу */
.reveal-on-scroll.is-visible {
  animation: none;
  opacity: 1;
  transform: translateY(0);
}
/* No-JS fallback — якщо <html> має no-js клас або взагалі JS вимкнено */
.no-js .reveal-on-scroll {
  opacity: 1;
  transform: none;
}

/* ---------- 5. HERO ANIMATIONS — safer на мобільному ---------- */
@media (max-width: 768px) {
  /* Швидші анімації на мобільному, менше delays */
  .page-hero .page-meta { animation-delay: 0.15s; }
  .page-hero .tldr-block { animation-delay: 0.2s; }
  .page-hero .section-intro { animation-delay: 0.25s; }
  .page-hero .hero-cta-row { animation-delay: 0.3s; }
}

/* ---------- 6. ROI CALCULATOR — кращі мобільні відступи ---------- */
@media (max-width: 640px) {
  .roi-calculator {
    padding: 1.5rem 1.25rem;
  }
  .roi-title {
    font-size: 1.25rem;
    line-height: 1.3;
  }
  .roi-subtitle {
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
  }
  .roi-result-value {
    font-size: 2.25rem;
  }
}

/* ---------- 7. SECTION NUMBERS — менші на мобільному ---------- */
@media (max-width: 480px) {
  .section-number {
    font-size: 4rem;
  }
  .numbered-section {
    padding-top: 2rem;
    margin-top: 1.5rem;
  }
}

/* ---------- 8. AURORA — менше performance impact на мобільному ---------- */
@media (max-width: 768px) {
  .page-hero::before {
    /* Менший blur і простіший gradient на мобільному для performance */
    filter: blur(30px);
    animation-duration: 30s;
  }
}

/* ---------- 9. CALLOUTS — кращий padding ---------- */
@media (max-width: 640px) {
  .callout {
    padding: 1.25rem 1rem;
    border-radius: 10px;
  }
  .callout-icon {
    font-size: 0.88rem;
    margin-bottom: 0.6rem;
  }
  .callout p {
    font-size: 0.88rem;
  }
}

/* ---------- 10. TLDR — мобільні відступи ---------- */
@media (max-width: 640px) {
  .tldr-block {
    padding: 1.25rem 1.1rem;
    margin: 1.5rem 0 2rem;
    border-radius: 10px;
  }
  .tldr-block p {
    font-size: 0.92rem;
    line-height: 1.6;
  }
}

/* ---------- 11. AUTHOR BLOCK — стек на мобільному (вже є але посилюємо) ---------- */
@media (max-width: 640px) {
  .author-block {
    padding: 1.25rem 1rem;
    gap: 1rem;
  }
  .author-avatar {
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
  }
  .author-name {
    font-size: 1rem;
  }
  .author-bio {
    font-size: 0.88rem;
    line-height: 1.6;
  }
  .author-links {
    gap: 0.85rem 1.25rem;
    font-size: 0.82rem;
  }
}

/* ---------- 12. PAGE META — компактніше на мобільному ---------- */
@media (max-width: 640px) {
  .page-meta {
    gap: 0.85rem;
    font-size: 0.78rem;
    margin: 1rem 0 1.5rem;
  }
}

/* ---------- 13. SECTION INTRO TEXT — менший шрифт на мобільному ---------- */
@media (max-width: 640px) {
  .section-intro {
    font-size: 0.95rem;
    line-height: 1.65;
  }
}

/* ---------- 14. PRICING tier badge MOST COMMON — fix overflow на мобільному ---------- */
@media (max-width: 768px) {
  /* MOST COMMON badge має йти у nowrap і не ламати layout */
  .comparison-table td span[style*="background:var(--cyan)"] {
    display: inline-block;
    white-space: nowrap;
    margin-top: 0.25rem;
    margin-left: 0;
  }
}


/* Pricing-specific mobile fix: outcome/what-we-do grid layouts with inline styles */
@media (max-width: 768px) {
  /* All inline-style grid-template-columns:1fr 2fr need to stack on mobile */
  div[style*="grid-template-columns: 1fr 2fr"],
  div[style*="grid-template-columns:1fr 2fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    padding: 1.25rem 1.25rem !important;
  }
  /* The header row labels (Outcome / What we do) — show as single label на мобільному */
  div[style*="background: var(--cyan-light)"][style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }
  div[style*="background: var(--cyan-light)"][style*="grid-template-columns"] > div:last-child {
    display: none;  /* ховаю "What we do" header, бо вже не grid */
  }
}
