/* ============================================================
   Smoothness overlay — refines easing, reveals, hovers, imagery
   Loaded after site.css to override timings without touching it.
   ============================================================ */

:root {
  --ease-soft: cubic-bezier(.22,.61,.36,1);
  --ease-out-quint: cubic-bezier(.23,1,.32,1);
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  body { scroll-behavior: smooth; }
}

/* ---- Page-load fade ---- */
@keyframes syc-page-in {
  from { opacity: 0; transform: translateY(6px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}
main { animation: syc-page-in .9s var(--ease-out-quint) both; }

/* ---- Smoother scroll-reveal: longer ease, stagger, blur fade ---- */
.reveal {
  transition:
    opacity 1s var(--ease-out-quint),
    transform 1s var(--ease-out-quint),
    filter .9s var(--ease-out-quint) !important;
  transform: translateY(28px) !important;
  filter: blur(8px);
}
.reveal.is-visible { transform: none !important; filter: none; }

/* Stagger children inside grids that already use .reveal */
.pillars.reveal.is-visible .pillar,
.tx-grid.reveal.is-visible .tx-card,
.num-grid.reveal.is-visible > div,
.case-list .case.reveal.is-visible > * {
  animation: syc-stagger .9s var(--ease-out-quint) both;
}
.pillars.reveal.is-visible .pillar:nth-child(1),
.tx-grid.reveal.is-visible .tx-card:nth-child(1),
.num-grid.reveal.is-visible > div:nth-child(1) { animation-delay: .05s; }
.pillars.reveal.is-visible .pillar:nth-child(2),
.tx-grid.reveal.is-visible .tx-card:nth-child(2),
.num-grid.reveal.is-visible > div:nth-child(2) { animation-delay: .15s; }
.pillars.reveal.is-visible .pillar:nth-child(3),
.tx-grid.reveal.is-visible .tx-card:nth-child(3),
.num-grid.reveal.is-visible > div:nth-child(3) { animation-delay: .25s; }
.pillars.reveal.is-visible .pillar:nth-child(4),
.tx-grid.reveal.is-visible .tx-card:nth-child(4),
.num-grid.reveal.is-visible > div:nth-child(4) { animation-delay: .35s; }
@keyframes syc-stagger {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Buttons: softer ease + subtle lift ---- */
.btn {
  transition: transform .35s var(--ease-soft),
              background .35s var(--ease-soft),
              border-color .35s var(--ease-soft),
              color .35s var(--ease-soft),
              box-shadow .35s var(--ease-soft) !important;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -14px rgba(0,0,0,.25); }
.btn .arrow { transition: transform .35s var(--ease-soft) !important; }
.btn:hover .arrow { transform: translateX(4px); }

/* ---- Nav links: soft underline ---- */
.nav-links a { position: relative; transition: color .25s var(--ease-soft) !important; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 1px; background: currentColor; opacity: 0;
  transform: scaleX(.2); transform-origin: left;
  transition: transform .45s var(--ease-out-quint), opacity .3s var(--ease-soft);
}
.nav-links a:hover::after { opacity: .6; transform: scaleX(1); }

/* ---- Pillars / case / treatment cards: lift + glow ---- */
.pillar, .tx-card, .case, .proof-card, .step, .ai-feat {
  transition: transform .5s var(--ease-out-quint),
              box-shadow .5s var(--ease-out-quint),
              border-color .5s var(--ease-out-quint) !important;
  will-change: transform;
}
.pillar:hover, .tx-card:hover, .case:hover, .proof-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px -28px rgba(15,61,46,.18);
}

/* ---- Treatment imagery ---- */
.tx-card { overflow: hidden; }
.tx-photo {
  position: relative;
  margin: -1.5rem -1.5rem 1.25rem;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: #0F3D2E;
}
.tx-photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scale(1.02);
  transition: transform 1.2s var(--ease-out-quint), filter .6s var(--ease-soft);
  filter: saturate(.95);
}
.tx-card:hover .tx-photo img { transform: scale(1.06); filter: saturate(1.05); }
.tx-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15,61,46,0) 55%, rgba(15,61,46,.18) 100%);
  pointer-events: none;
}

/* ---- Hero visual: gentle float + entrance ---- */
@keyframes syc-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}
.hero-visual { animation: syc-float 9s ease-in-out infinite; }
.hero-visual { transition: transform .6s var(--ease-out-quint); }
.hero-visual:hover { animation-play-state: paused; }

/* Hero copy entrance */
.hero-copy > * { animation: syc-page-in .9s var(--ease-out-quint) both; }
.hero-copy > *:nth-child(1) { animation-delay: .05s; }
.hero-copy > *:nth-child(2) { animation-delay: .15s; }
.hero-copy > *:nth-child(3) { animation-delay: .25s; }
.hero-copy > *:nth-child(4) { animation-delay: .35s; }
.hero-copy > *:nth-child(5) { animation-delay: .45s; }

/* ---- Footer + sticky bar smoothing ---- */
.sticky-cta { transition: transform .5s var(--ease-out-quint), opacity .4s var(--ease-soft) !important; }

/* ---- AI section ambient glow (no extra DOM needed) ---- */
.ai-band { position: relative; overflow: hidden; }
.ai-band::before {
  content: "";
  position: absolute; inset: -20% -10% auto auto;
  width: 60%; height: 80%;
  background: radial-gradient(closest-side, rgba(43,181,115,.18), transparent 70%);
  pointer-events: none;
  filter: blur(20px);
  animation: syc-float 12s ease-in-out infinite;
}

/* ---- Watch player frame: subtle hover lift ---- */
.watch-frame { transition: transform .6s var(--ease-out-quint), box-shadow .6s var(--ease-out-quint); }
.watch-frame:hover { transform: translateY(-3px); box-shadow: 0 30px 80px -32px rgba(15,61,46,.28); }

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

/* ============================================================
   Universal responsive polish — works across all viewports
   ============================================================ */

/* Prevent any horizontal overflow (accidental wide elements) */
html, body { overflow-x: hidden; max-width: 100%; }
img, svg, video, iframe { max-width: 100%; height: auto; }
iframe { display: block; }

/* Long words / URLs shouldn't blow out narrow screens */
h1, h2, h3, h4, p, li, a, blockquote {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* Container side padding scales with viewport */
.container, .wrap, .shell, .inner, main > section {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* Touch targets: min 44px on mobile */
@media (max-width: 880px) {
  .btn, .nav-links a, button, a.btn {
    min-height: 44px;
  }
}

/* Tighter typography on small screens */
@media (max-width: 640px) {
  h1 { font-size: clamp(1.9rem, 8.5vw, 2.6rem) !important; line-height: 1.1; }
  h2 { font-size: clamp(1.6rem, 6.5vw, 2.1rem) !important; line-height: 1.15; }
  h3 { font-size: clamp(1.2rem, 5vw, 1.5rem) !important; }
  .hero-copy p, section p { font-size: 1rem; line-height: 1.6; }

  /* Stack any leftover 2-col grids */
  .pillars, .tx-grid, .num-grid, .step-grid, .proof-grid,
  .case-list, .ai-grid, .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Buttons fill width for easier tapping */
  .hero .actions .btn,
  .cta-row .btn,
  .hero-cta { width: 100%; justify-content: center; }
  .cta-row { flex-direction: column; align-items: stretch; }

  /* Cards: tighter padding */
  .pillar, .tx-card, .case, .proof-card, .step, .ai-feat,
  .num-grid > div, .faq-item {
    padding: 1.25rem !important;
  }

  /* Reduce huge section paddings */
  section { padding-top: 3rem !important; padding-bottom: 3rem !important; }
}

/* Sticky CTA: don't overlap last content; readable on phones */
.sticky-cta {
  max-width: calc(100vw - 1.5rem);
  left: 50% !important;
  transform: translateX(-50%);
  bottom: max(.75rem, env(safe-area-inset-bottom)) !important;
}
@media (max-width: 480px) {
  .sticky-cta { font-size: .9rem; padding: .6rem .8rem !important; }
}
main { padding-bottom: 0; }

/* Header: keep brand and CTA from colliding on tiny screens */
@media (max-width: 380px) {
  .site-header .logo span, .brand span { font-size: .95rem; }
  .site-header .btn { padding-left: .75rem; padding-right: .75rem; }
}

/* Tables / wide blocks scroll horizontally instead of breaking layout */
table { display: block; width: 100%; overflow-x: auto; }

/* Phone-frame AI demo: scale on tiny screens */
@media (max-width: 360px) {
  .phone, .ai-phone { transform: scale(.92); transform-origin: top center; }
}

/* Reduce hero visual height on phones so CTA stays reachable */
@media (max-width: 640px) {
  .hero-visual, .pipeline-card { max-height: 60vh; }
}

/* Ultra-wide screens: cap content width, keep it centered */
@media (min-width: 1600px) {
  .container, .wrap, .shell, .inner { max-width: 1320px; margin-left: auto; margin-right: auto; }
}

/* ============================================================
   Hero pipeline chart — responsive simplification
   ============================================================ */

/* Tablet: tighten the chart, drop interactive dots (touch can't hover) */
@media (max-width: 880px) {
  .hero-visual { padding: 18px !important; border-radius: 12px; }
  .hv-chart { height: 200px !important; }
  .hv-dots, .hv-guide, .hv-tooltip { display: none !important; }
  .hv-grid-line:nth-child(2),
  .hv-grid-line:nth-child(4) { display: none; }       /* keep only top/mid/bottom */
  .hv-foot { gap: 16px !important; }
  .hv-foot .v { font-size: 1.1rem !important; }
  .hv-foot .k { font-size: 11px !important; }
  .hv-foot .delta { display: inline; font-size: 11px; margin-left: 6px; }
}

/* Mobile: simpler still — 2 KPI tiles, condensed header, shorter chart */
@media (max-width: 640px) {
  .hero-visual {
    padding: 16px !important;
    margin-top: 24px;
    animation: none !important;          /* skip the float on phones */
  }
  .hv-head { align-items: flex-start; gap: 8px; }
  .hv-title { font-size: .92rem !important; line-height: 1.25; }
  .hv-sub   { display: none !important; } /* "Aggregate · 14 active clinics" — noise on phones */
  .hv-badge { font-size: 10px !important; padding: 3px 8px !important; }

  .hv-chart {
    height: 160px !important;
    margin: 12px 0 !important;
  }
  .hv-grid-line { opacity: .5; }
  .hv-axis { font-size: 10px !important; letter-spacing: .12em; }

  /* Drop the 3rd KPI (avg cost) on phones — keep the headline numbers */
  .hv-foot {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    padding-top: 12px !important;
  }
  .hv-foot > div:nth-child(3) { display: none !important; }
  .hv-foot .v { font-size: 1.05rem !important; }
}

/* Ultra-narrow: single KPI row, even smaller chart */
@media (max-width: 380px) {
  .hv-chart { height: 140px !important; }
  .hv-foot {
    grid-template-columns: 1fr !important;
    text-align: left;
  }
  .hv-foot > div { display: flex; align-items: baseline; gap: 8px; }
  .hv-foot .k { color: var(--ink-3); }
}

/* ============================================================
   Case Studies — horizontal snap scroller with pager
   ============================================================ */

.case-scroller { position: relative; }

.case-scroller .case-list {
  display: grid !important;
  grid-auto-flow: column !important;
  grid-auto-columns: 100%;
  gap: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 6px 2px 18px;       /* room for shadow & focus ring */
  margin: 0 -2px;
  scroll-behavior: smooth;
}
.case-scroller .case-list::-webkit-scrollbar { display: none; }

.case-scroller .case {
  scroll-snap-align: center;
  scroll-snap-stop: always;
  min-width: 0;
  width: 100%;
  margin: 0 !important;        /* override stacked-list margins */
}

/* Edge fade removed — was clipping case study text */
.case-scroller::before,
.case-scroller::after { display: none !important; }

/* Controls bar */
.case-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 24px;
}

.case-nav {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: transform .25s var(--ease-soft),
              background .25s var(--ease-soft),
              color .25s var(--ease-soft),
              border-color .25s var(--ease-soft),
              box-shadow .25s var(--ease-soft),
              opacity .25s var(--ease-soft);
  box-shadow: 0 1px 0 rgba(15,26,21,.02);
}
.case-nav:hover {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -16px rgba(15,61,46,.4);
}
.case-nav:active { transform: translateY(0); }
.case-nav:disabled {
  opacity: .35; cursor: not-allowed;
  transform: none; box-shadow: none;
  background: #fff; color: var(--accent); border-color: var(--rule);
}
.case-nav.next:hover svg { transform: translateX(2px); }
.case-nav.prev:hover svg { transform: translateX(-2px); }
.case-nav svg { transition: transform .25s var(--ease-soft); }

/* Pager */
.case-pager {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  box-shadow: 0 1px 0 rgba(15,26,21,.02);
}
.case-pip {
  appearance: none; border: 0; background: transparent;
  font: inherit; letter-spacing: inherit;
  color: var(--ink-3);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s var(--ease-soft),
              background .3s var(--ease-soft),
              transform .25s var(--ease-soft);
}
.case-pip:hover { color: var(--accent); }
.case-pip.is-active {
  color: var(--paper);
  background: var(--accent);
  transform: scale(1.02);
}
.case-pip-rule {
  width: 12px; height: 1px; background: var(--rule-2);
}

/* Hide stacked-list rules between cases (we're side-by-side now) */
.case-scroller .case + .case { border-top: 0 !important; padding-top: 0 !important; }

/* Responsive: slightly tighter on phones */
@media (max-width: 880px) {
  .case-scroller .case-list { gap: 16px; }
  .case-controls { gap: 12px; margin-top: 18px; }
  .case-nav { width: 40px; height: 40px; }
  .case-pager { padding: 4px 6px; gap: 6px; font-size: 11px; }
  .case-pip { padding: 5px 8px; }
}
