/* motion.css — the site's animation layer (loaded after style.css, driven by js/motion.js).
   Same approach as voltygrid.com: no library, CSS transitions/keyframes + one IntersectionObserver.
   Everything sits behind html.motion (set by a tiny inline script) and prefers-reduced-motion,
   so without JS or with "reduce motion" the site is simply static and fully visible. */

:root {
  --ease-out:  cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

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

  /* ── Page-to-page transitions (Chrome, Edge, Safari 18+; others just navigate normally) ── */
  @view-transition { navigation: auto; }
  nav#navbar { view-transition-name: site-nav; }          /* the menu stays put while the page changes */
  ::view-transition-old(root) { animation: vt-out 0.32s cubic-bezier(0.4, 0, 1, 1) both; }
  ::view-transition-new(root) { animation: vt-in 0.6s var(--ease-out) both; }
  @keyframes vt-out { to   { opacity: 0; transform: translateY(-10px); } }
  @keyframes vt-in  { from { opacity: 0; transform: translateY(18px); } }

  /* ── Hero: very slow zoom on the photo + staggered intro ── */
  .hero-bg { animation: slowzoom 14s var(--ease-soft) both; }
  @keyframes slowzoom { from { transform: scale(1.08); } }
  html.motion .hero-content { animation: none; }
  html.motion .hero-eyebrow { animation: fade 1.2s ease 0.1s both; }
  html.motion .hero-sub     { animation: fadeup 1.2s var(--ease-out) 0.5s both; }
  html.motion .hero-btns    { animation: fadeup 1.2s var(--ease-out) 0.65s both; }
  html.motion .scroll-hint  { animation: fade 1.5s ease 1.2s both; }
  @keyframes fade   { from { opacity: 0; } }
  @keyframes fadeup { from { opacity: 0; transform: translateY(18px); } }

  /* ── Headings rise line by line out of a mask (js wraps each <br>-line in .ln) ── */
  .ln { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
  .ln > span { display: block; }
  html.motion .lines-now .ln > span { animation: lnup 1.3s var(--ease-out) both; animation-delay: calc(0.15s * var(--i, 0) + 0.15s); }
  html.motion .lines-scroll .ln > span { transform: translateY(105%); transition: transform 1.2s var(--ease-out); transition-delay: calc(0.12s * var(--i, 0)); }
  html.motion .lines-scroll.in .ln > span { transform: none; }
  @keyframes lnup { from { transform: translateY(105%); } }

  /* ── Content fades up as it scrolls into view; siblings in a grid follow each other ── */
  html.motion .rv { opacity: 0; transform: translateY(24px); transition: opacity 1s var(--ease-out), transform 1s var(--ease-out); transition-delay: calc(90ms * var(--d, 0)); }
  html.motion .rv.in { opacity: 1; transform: none; }
  html.motion .gold-divider.rv { transform: scaleX(0); transform-origin: left; transition-property: opacity, transform; }
  html.motion .gold-divider.rv.in { transform: none; }

  /* ── Photos: curtain opens upward while the image settles from a slight zoom ──
     The clip sits on the <img>, not the container: Chrome treats a fully clipped element as
     "not visible", so the IntersectionObserver would never fire. The separate `scale` property
     keeps existing hover effects on `transform` working. */
  html.motion .rv-img img {
    clip-path: inset(100% 0 0 0); scale: 1.12;
    transition: transform 0.6s var(--ease-out), filter 0.4s, clip-path 1.3s var(--ease-soft), scale 1.8s var(--ease-soft);
    transition-delay: 0s, 0s, calc(80ms * var(--d, 0)), calc(80ms * var(--d, 0));
  }
  html.motion .rv-img.in img { clip-path: inset(0); scale: 1; }

  /* ── Header slims down once you scroll ── */
  nav { transition: background 0.5s, padding 0.5s var(--ease-out), border-color 0.5s; }
  nav.scrolled { padding-top: 0.9rem; padding-bottom: 0.9rem; }
  .nav-logo img { transition: height 0.5s var(--ease-out), opacity 0.3s; }

  /* ── Lightbox opens softly, photos cross-fade when browsing ── */
  .lightbox.open { animation: fade 0.35s ease both; }
  .lightbox.open img { animation: lbin 0.6s var(--ease-out) both; }
  .lightbox img.swap { animation: lbswap 0.45s var(--ease-out) both; }
  @keyframes lbin   { from { opacity: 0; transform: scale(0.96); } }
  @keyframes lbswap { from { opacity: 0.2; transform: scale(0.985); } }
}

/* ── Buttons: colour sweeps in from the left on hover (also fine without motion: instant) ── */
.btn-primary, .btn-gold, .btn-dark { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::before, .btn-gold::before, .btn-dark::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--sweep); transform: scaleX(0); transform-origin: right;
  transition: transform 0.55s var(--ease-out);
}
.btn-primary:hover::before, .btn-gold:hover::before, .btn-dark:hover::before { transform: scaleX(1); transform-origin: left; }
.btn-primary { --sweep: var(--gold); transition: color 0.35s, border-color 0.35s; }
.btn-primary:hover { background: transparent; color: var(--black); }
.btn-gold { --sweep: var(--gold-light); }
.btn-gold:hover { background: var(--gold); }
.btn-dark { --sweep: #222; }
.btn-dark:hover { background: var(--black); }
.cta-sec .btn-dark { --sweep: var(--gold); transition: color 0.35s; }
.cta-sec .btn-dark:hover { color: var(--black); }

/* ── Back-to-top button (added by js/motion.js) ── */
.totop {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(201,169,110,0.5); background: rgba(10,10,10,0.75); backdrop-filter: blur(8px);
  color: var(--gold); font-size: 1rem; cursor: pointer;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out), background 0.3s, color 0.3s;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover, .totop:focus-visible { background: var(--gold); color: var(--black); outline: none; }

/* ── Falling feather that follows the scroll (js/motion.js). Decorative, behind clicks. ── */
.feather {
  position: fixed; top: 0; right: clamp(1rem, 5vw, 5rem); z-index: 40;
  width: 32px; height: 92px; color: var(--gold);
  opacity: 0; pointer-events: none; will-change: transform;
  perspective: 420px;
  animation: feather-in 1.6s var(--ease-out) 0.8s forwards;
}
.feather-3d { width: 100%; height: 100%; transform-origin: 50% 55%; will-change: transform; }
.feather svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.3)); }
@keyframes feather-in { to { opacity: 0.55; } }
@media (max-width: 768px) { .feather { width: 22px; height: 64px; right: 0.8rem; } }
@media (prefers-reduced-motion: reduce) { .feather { display: none; } }
/* Never over a photo in the lightbox. */
body:has(.lightbox.open) .feather { opacity: 0 !important; transition: opacity 0.3s; }

/* ── Text on paper is written, word by word, as with a pen (js/motion.js wraps the words in .w) ── */
@media (prefers-reduced-motion: no-preference) {
  html.motion .write .w {
    display: inline-block;
    -webkit-mask: linear-gradient(90deg, #000 40%, transparent 60%) 100% 0 / 260% 100% no-repeat;
            mask: linear-gradient(90deg, #000 40%, transparent 60%) 100% 0 / 260% 100% no-repeat;
  }
  html.motion .write.in .w { animation: ink-write .42s linear forwards; animation-delay: var(--wd, 0ms); }
  @keyframes ink-write { to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
}
