/* Winkler Health Hub — motion layer.
   Adds entrance, scroll-reveal, parallax and hover motion on top of styles.css.
   Everything here is cosmetic: with motion.js absent or reduced motion on, the page renders fully at rest. */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur: 0.8s;
  --lift-shadow: 0 18px 38px -22px rgba(10, 45, 75, 0.45);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --lift-shadow: 0 18px 38px -20px rgba(0, 0, 0, 0.7); } }
:root[data-theme="dark"] { --lift-shadow: 0 18px 38px -20px rgba(0, 0, 0, 0.7); }

html { scroll-padding-top: 96px; }

/* ---------- Page load and page-to-page transitions ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 0.28s var(--ease-in-out) both vt-out; }
::view-transition-new(root) { animation: 0.45s var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

body { animation: page-in 0.6s var(--ease-out) both; }
@keyframes page-in { from { opacity: 0; } }

/* Thin brand-coloured progress line across the top while the page settles */
.load-bar {
  position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none;
  background: linear-gradient(90deg, #1a6aa8, #3fa86a 60%, #9ad84a);
  transform-origin: 0 50%; transform: scaleX(0);
  animation: load-bar 1.1s var(--ease-out) forwards;
}
@keyframes load-bar {
  0% { transform: scaleX(0); opacity: 1; }
  70% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

/* ---------- Header ---------- */
.site-header { transition: box-shadow 0.4s var(--ease-out), background-color 0.4s var(--ease-out); }
.site-header .wrap { transition: padding 0.4s var(--ease-out); }
.site-header.is-scrolled { box-shadow: 0 10px 30px -22px rgba(10, 45, 75, 0.55); }
.site-header.is-scrolled .wrap { padding-block: 6px; }
.brand img { transition: transform 0.6s var(--ease-out); }
.brand:hover img { transform: rotate(-6deg) scale(1.05); }

.nav a:not(.btn) { position: relative; transition: color 0.25s ease, background-color 0.25s ease; }
.nav a:not(.btn)::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transform: scaleX(0); transform-origin: 50% 50%; transition: transform 0.35s var(--ease-out);
}
.nav a:not(.btn):hover { background: transparent; color: var(--blue); }
.nav a:not(.btn):hover::after, .nav a[aria-current="page"]:not(.btn)::after { transform: scaleX(1); }
@media (max-width: 900px) {
  .nav.open { animation: menu-in 0.35s var(--ease-out) both; }
  .nav a:not(.btn)::after { left: 12px; right: auto; width: 32px; transform-origin: 0 50%; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  will-change: transform;
}
.btn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.7s var(--ease-out);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--lift-shadow); }
.btn:hover::after { transform: translateX(120%); }
.btn:active { transform: translateY(0) scale(0.97); box-shadow: none; transition-duration: 0.12s; }
.btn-outline:hover { background: var(--tint); }

.more { display: inline-block; transition: transform 0.35s var(--ease-out), color 0.25s ease; }
.more:hover { transform: translateX(4px); }

/* ---------- Cards and interactive blocks ---------- */
.card { transition: transform 0.45s var(--ease-out), box-shadow 0.45s var(--ease-out), border-color 0.3s ease; }
.card .icon { transition: transform 0.45s var(--ease-out), background-color 0.3s ease, color 0.3s ease; }
.card:has(a.more):hover, .grid .card:hover, .doc:hover { transform: translateY(-4px); box-shadow: var(--lift-shadow); border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); }
.card:hover .icon { transform: translateY(-2px) rotate(-6deg); background: var(--blue); color: var(--surface); }
.card.urgent:hover .icon { background: var(--urgent); color: var(--surface); }
form.card:hover, .success:hover { transform: none; box-shadow: none; }

.fact { transition: border-color 0.3s ease, transform 0.4s var(--ease-out); }
.fact:hover { border-left-color: var(--blue); transform: translateX(3px); }

.value h3 { transition: letter-spacing 0.5s var(--ease-out); }
.value:hover h3 { letter-spacing: 0.01em; }

.offer-list li::before { transition: transform 0.35s var(--ease-out), background-color 0.3s ease; }
.offer-list li:hover::before { transform: translateY(-2px) scale(1.6); background: var(--blue); }

.hours tr { transition: background-color 0.25s ease; }
.hours tr:hover { background: var(--tint); }

.contact-item .icon { transition: transform 0.45s var(--ease-out), background-color 0.3s ease, color 0.3s ease; }
.contact-item:hover .icon { transform: rotate(-8deg) scale(1.06); background: var(--blue); color: var(--surface); }

.tags span { transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease; }
.tags span:hover { background: var(--tint); color: var(--ink); border-color: var(--blue); }

.avatar img { transition: transform 0.8s var(--ease-out); }
.doc:hover .avatar img { transform: scale(1.06); }

.site-footer a { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.35s var(--ease-out), color 0.25s ease; }
.site-footer a:hover { background-size: 100% 1px; color: #fff; }
.foot-brand img { transition: transform 0.6s var(--ease-out); }
.foot-brand img:hover { transform: translateY(-3px); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; isolation: isolate; }
.hero::before, .hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); pointer-events: none;
  width: 460px; height: 460px; max-width: 70vw; max-height: 70vw;
}
.hero::before { right: -120px; top: -140px; background: color-mix(in srgb, var(--leaf) 35%, transparent); animation: drift-a 18s var(--ease-in-out) infinite alternate; }
.hero::after { left: 30%; bottom: -340px; background: color-mix(in srgb, var(--blue) 14%, transparent); animation: drift-b 22s var(--ease-in-out) infinite alternate; }
@keyframes drift-a { to { transform: translate(-60px, 50px) scale(1.12); } }
@keyframes drift-b { to { transform: translate(80px, -40px) scale(0.92); } }

.hero-copy > * { animation: rise 0.9s var(--ease-out) both; }
.hero-copy > .open-date { animation-delay: 0.1s; }
.hero-copy > h1 { animation-delay: 0.18s; }
.hero-copy > .lede { animation-delay: 0.55s; }
.hero-copy > .btn-row { animation-delay: 0.7s; }
.hero-copy > .facts { animation: none; }
.hero .fact { animation: rise 0.8s var(--ease-out) both; }
.hero .fact:nth-child(1) { animation-delay: 0.85s; }
.hero .fact:nth-child(2) { animation-delay: 0.95s; }
.hero .fact:nth-child(3) { animation-delay: 1.05s; }
.open-date span { animation: pulse-pill 2.8s ease-in-out 1.4s 2; }
@keyframes pulse-pill { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--green) 25%, transparent); } }

/* Word-by-word headline (motion.js wraps each word) */
h1[data-split] { animation: none !important; }
h1[data-split] .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
h1[data-split] .wi { display: inline-block; animation: word-up 0.9s var(--ease-out) both; animation-delay: calc(var(--base, 0.15s) + var(--i) * 0.06s); }
@keyframes word-up { from { transform: translateY(105%); opacity: 0; } }

.hero-photo { animation: photo-reveal 1.3s var(--ease-out) 0.2s both; transition: box-shadow 0.6s var(--ease-out); }
.hero-photo img { scale: 1.08; animation: photo-zoom 2.4s var(--ease-out) 0.2s; transition: scale 1.2s var(--ease-out); will-change: translate; }
.hero-photo:hover img { scale: 1.12; }
.hero-photo:hover { box-shadow: 0 28px 60px -28px rgba(10, 40, 60, 0.55); }
@keyframes photo-reveal { from { clip-path: inset(12% 12% 12% 12% round 18px); opacity: 0; } to { clip-path: inset(0 0 0 0 round 18px); opacity: 1; } }
@keyframes photo-zoom { from { scale: 1.25; } to { scale: 1.08; } }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* Inner page headers */
.page-head .wrap > * { animation: rise 0.85s var(--ease-out) both; }
.page-head .wrap > :nth-child(1) { animation-delay: 0.05s; }
.page-head .wrap > :nth-child(2) { animation-delay: 0.12s; }
.page-head .wrap > :nth-child(3) { animation-delay: 0.45s; }
.page-head h1[data-split] { --base: 0.12s; }
.page-head { position: relative; overflow: hidden; isolation: isolate; }
.page-head::before {
  content: ""; position: absolute; z-index: -1; right: -140px; top: -180px; width: 420px; height: 420px; max-width: 70vw; border-radius: 50%;
  background: color-mix(in srgb, var(--leaf) 22%, transparent); filter: blur(70px); pointer-events: none;
  animation: drift-a 20s var(--ease-in-out) infinite alternate;
}

/* ---------- Scroll reveals (motion.js tags elements with data-reveal) ---------- */
.motion-ready [data-reveal] {
  opacity: 0; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), clip-path 1s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 80ms);
}
.motion-ready [data-reveal="up"] { transform: translateY(28px); }
.motion-ready [data-reveal="left"] { transform: translateX(-28px); }
.motion-ready [data-reveal="zoom"] { transform: scale(0.92); }
.motion-ready [data-reveal="clip"] { clip-path: inset(0 0 100% 0); }
.motion-ready [data-reveal].is-in { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }

.eyebrow.tracked { animation: tracking-in 1.1s var(--ease-out) both; }
/* Section headings: words rise in one after another */
.motion-ready .split-on-view .wi { display: inline-block; transform: translateY(105%); opacity: 0; transition: transform 0.9s var(--ease-out), opacity 0.9s var(--ease-out); transition-delay: calc(0.08s + var(--i) * 0.05s); }
.motion-ready .split-on-view.is-in .wi { transform: none; opacity: 1; }
.split-on-view .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.split-on-view .wi { animation: none !important; }
@keyframes tracking-in { from { letter-spacing: 0.32em; } }

/* CTA band: slow gradient drift and parallax sheen */
.cta-band { background-size: 180% 180%; animation: band-shift 16s var(--ease-in-out) infinite alternate; position: relative; overflow: hidden; }
.cta-band::before {
  content: ""; position: absolute; inset: -40% -10%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.14), transparent 70%) no-repeat 20% 50% / 50% 120%;
  translate: 0 var(--py, 0px);
}
@keyframes band-shift { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }

/* ---------- Reduced motion: everything at rest, no movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .load-bar { display: none; }
  .hero-photo img { scale: 1; translate: none !important; }
  .cta-band::before { translate: none; }
  @view-transition { navigation: none; }
}
