/**
 * Corey Shirley — Motion & Transitions Layer
 * ---------------------------------------------------------------------------
 * A restrained, editorial motion system for a luxury real-estate brand.
 * Design intent: motion should feel like the page *settling into place*, never
 * like an effect demanding attention. Slow ease-out curves, short travel,
 * transform/opacity only. No bounce, no elastic, no uniform fade-on-everything.
 *
 * Safe by construction:
 *  - All reveal pre-states are gated behind `html.cs-motion`, which is only
 *    added by an inline <head> guard when JS + IntersectionObserver are present
 *    AND the visitor has NOT requested reduced motion. Without it, content is
 *    fully visible — no JS, no flash, no blank sections.
 *  - prefers-reduced-motion collapses everything to a quiet crossfade.
 *  - A JS failsafe reveals anything still hidden after load (hidden tabs /
 *    headless renderers never ship a blank section).
 *
 * Pairs with assets/js/site-transitions.js. Enqueued globally.
 * @package CoreyShirley
 */

/* ===========================================================================
   1. MOTION TOKENS
   =========================================================================== */
:root {
  /* Editorial ease-outs — letters and panels glide to a stop, never overshoot */
  --cs-ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --cs-ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --cs-ease-out-soft:  cubic-bezier(0.33, 1, 0.68, 1);
  --cs-ease-inout:     cubic-bezier(0.65, 0, 0.35, 1);

  /* Durations */
  --cs-dur-fast: 0.40s;   /* hovers, focus, small UI */
  --cs-dur:      0.72s;   /* standard reveal */
  --cs-dur-slow: 1.05s;   /* hero / large surfaces */

  /* Reveal travel — short on purpose. Restraint reads as luxury. */
  --cs-reveal-y: 26px;

  /* Brand accent (mirrors the theme gold; override per-project) */
  --cs-accent: #d4af37;
}

/* ===========================================================================
   2. REVEAL-ON-SCROLL  (opt-in: add class .cs-reveal in markup or via JS)
   ---------------------------------------------------------------------------
   Default state is VISIBLE. The hidden pre-state only exists while the page is
   motion-capable (html.cs-motion). JS adds .cs-in when the element scrolls in.
   =========================================================================== */
html.cs-motion .cs-reveal {
  opacity: 0;
  transform: translate3d(0, var(--cs-reveal-y), 0);
  transition:
    opacity   var(--cs-dur) var(--cs-ease-out-quint),
    transform var(--cs-dur) var(--cs-ease-out-expo);
  transition-delay: calc(var(--cs-i, 0) * 90ms);   /* per-item stagger */
  will-change: opacity, transform;
}
html.cs-motion .cs-reveal.cs-in {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Repeated content cards get the same refined sitewide cadence: a shorter
   entrance and capped 60ms stagger that supports scanning instead of delaying. */
html.cs-motion .cs-reveal.cs-reveal--card {
  --cs-dur: 0.32s;
  --cs-reveal-y: 16px;
  transition-delay: calc(var(--cs-i, 0) * 60ms);
}

/* drop the GPU hint once settled */
html.cs-motion .cs-reveal.cs-in { will-change: auto; }

/* Directional + scale variants — vary the entrance to fit the content, so the
   page never reads as one reflex applied to everything. */
html.cs-motion .cs-reveal--left  { transform: translate3d(calc(-1 * var(--cs-reveal-y)), 0, 0); }
html.cs-motion .cs-reveal--right { transform: translate3d(var(--cs-reveal-y), 0, 0); }
html.cs-motion .cs-reveal--scale { transform: scale(0.965); }
html.cs-motion .cs-reveal--still { transform: none; }            /* opacity-only */
html.cs-motion .cs-reveal--slow  { --cs-dur: var(--cs-dur-slow); }
html.cs-motion .cs-reveal--left.cs-in,
html.cs-motion .cs-reveal--right.cs-in,
html.cs-motion .cs-reveal--scale.cs-in { transform: none; }

/* ===========================================================================
   3. IMAGE — slow scale on hover/focus  (opt-in: .cs-zoom on the frame)
   ---------------------------------------------------------------------------
   The frame clips; the inner media drifts up in scale. A quiet, expensive-feeling
   gesture for property and portrait imagery. Frame keeps its own layout box, so
   nothing reflows.
   =========================================================================== */
html.cs-motion .cs-zoom {
  overflow: hidden;
  isolation: isolate;
}
html.cs-motion .cs-zoom > img,
html.cs-motion .cs-zoom > picture,
html.cs-motion .cs-zoom > .cs-zoom-media,
html.cs-motion .cs-zoom-media {
  transition: transform var(--cs-dur-slow) var(--cs-ease-out-expo);
  transform-origin: center;
  backface-visibility: hidden;
}
/* When the frame itself is the background-image layer, scale the frame's bg */
html.cs-motion .cs-zoom.cs-zoom--self {
  transition: transform var(--cs-dur-slow) var(--cs-ease-out-expo);
  transform-origin: center;
}
/* Site-specific: clip the property-spotlight so its scaled background layer
   (a .cs-zoom--self target) stays inside the frame. The overlay + content live
   inside this container, so clipping is safe. */
html.cs-motion .property-spotlight-container { overflow: hidden; }
@media (hover: hover) {
  html.cs-motion .cs-zoom:hover > img,
  html.cs-motion .cs-zoom:hover > picture,
  html.cs-motion .cs-zoom:hover > .cs-zoom-media,
  html.cs-motion .cs-zoom:focus-within > img,
  html.cs-motion .cs-zoom:focus-within .cs-zoom-media { transform: scale(1.055); }
  html.cs-motion .cs-zoom.cs-zoom--self:hover { transform: scale(1.045); }
}

/* ===========================================================================
   4. LINK UNDERLINE — draws in from the left  (opt-in: .cs-link)
   =========================================================================== */
.cs-link {
  position: relative;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size var(--cs-dur-fast) var(--cs-ease-out-expo);
}
@media (hover: hover) {
  .cs-link:hover,
  .cs-link:focus-visible { background-size: 100% 1px; }
}

/* ===========================================================================
   5. BUTTON / CTA — quiet rise + arrow nudge  (opt-in: .cs-rise)
   =========================================================================== */
.cs-rise {
  transition:
    transform var(--cs-dur-fast) var(--cs-ease-out-expo),
    box-shadow var(--cs-dur-fast) var(--cs-ease-out-expo);
}
@media (hover: hover) {
  .cs-rise:hover { transform: translateY(-2px); }
}
.cs-rise .cs-arrow,
.cs-rise [class*="arrow"] {
  transition: transform var(--cs-dur-fast) var(--cs-ease-out-expo);
}
@media (hover: hover) {
  .cs-rise:hover .cs-arrow,
  .cs-rise:hover [class*="arrow"] { transform: translateX(4px); }
}

/* ===========================================================================
   6. HEADER STATE — body.cs-scrolled hook (subtle; opt-in styling)
   ---------------------------------------------------------------------------
   JS toggles body.cs-scrolled past ~40px. Kept intentionally minimal here to
   avoid fighting the theme's existing header script; extend per project.
   =========================================================================== */
body .cs-scroll-target { transition: box-shadow var(--cs-dur-fast) var(--cs-ease-inout),
                                     background-color var(--cs-dur-fast) var(--cs-ease-inout); }

/* ===========================================================================
   7. ACCESSIBLE FOCUS — on-brand keyboard ring (global, additive)
   =========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cs-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ===========================================================================
   8. SMOOTH SCROLL — only when motion-capable
   =========================================================================== */
html.cs-motion { scroll-behavior: smooth; }

/* ===========================================================================
   9. REDUCED MOTION — non-negotiable.
   The head guard already withholds .cs-motion for these visitors, so reveals
   never hide. This block is belt-and-suspenders: anything that does animate
   collapses to a near-instant crossfade, and scaling/scroll easing is dropped.
   =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html .cs-reveal,
  html .cs-reveal.cs-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  html .cs-zoom > img,
  html .cs-zoom > picture,
  html .cs-zoom-media,
  html .cs-zoom.cs-zoom--self,
  .cs-link,
  .cs-rise,
  .cs-rise .cs-arrow {
    transition: none !important;
  }
  html .cs-zoom:hover > img,
  html .cs-zoom:focus-within .cs-zoom-media,
  html .cs-zoom.cs-zoom--self:hover { transform: none !important; }
}
