/* ==========================================================================
   Ryddhu AI motion and micro-interactions
   Load AFTER assets/home.css. Changes only motion, colour and outline:
   no layout, no sizes, no filters. Only opacity and transform animate,
   so nothing shifts the page. All of it is off for prefers-reduced-motion.
   ========================================================================== */

:root {
  --motion-fast: 160ms;     /* hover, press */
  --motion-base: 240ms;     /* borders, colours */
  --motion-slow: 640ms;     /* reveals */
  --motion-step: 70ms;      /* stagger between siblings */
  --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --focus-ring: 0 0 0 3px #ffffff, 0 0 0 5px var(--accent-primary, #0e7490);
}

/* --- 1. Scroll reveal choreography --------------------------------------
   home.js already adds .is-visible to [data-reveal]. Add
   data-reveal-stagger to a grid that has data-reveal: the grid itself
   stays put and its children rise in one after another (max 6 steps). */
.js [data-reveal][data-reveal-stagger] {
  opacity: 1;
  transform: none;
}
.js [data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--motion-slow) var(--motion-ease),
    transform var(--motion-slow) var(--motion-ease),
    border-color var(--motion-base) ease,
    box-shadow var(--motion-base) ease;
}
.js [data-reveal-stagger].is-visible > * {
  opacity: 1;
  transform: none;
}
.js [data-reveal-stagger].is-visible > :nth-child(2) { transition-delay: calc(var(--motion-step) * 1), calc(var(--motion-step) * 1), 0s, 0s; }
.js [data-reveal-stagger].is-visible > :nth-child(3) { transition-delay: calc(var(--motion-step) * 2), calc(var(--motion-step) * 2), 0s, 0s; }
.js [data-reveal-stagger].is-visible > :nth-child(4) { transition-delay: calc(var(--motion-step) * 3), calc(var(--motion-step) * 3), 0s, 0s; }
.js [data-reveal-stagger].is-visible > :nth-child(5) { transition-delay: calc(var(--motion-step) * 4), calc(var(--motion-step) * 4), 0s, 0s; }
.js [data-reveal-stagger].is-visible > :nth-child(n+6) { transition-delay: calc(var(--motion-step) * 5), calc(var(--motion-step) * 5), 0s, 0s; }

/* --- 2. Links -------------------------------------------------------------
   Underline firms up; nothing moves. */
.text-link,
main p a:not(.btn) {
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--motion-base) ease, text-decoration-color var(--motion-base) ease;
}
.text-link:hover,
main p a:not(.btn):hover {
  text-decoration-color: currentColor;
}

/* --- 3. Buttons -----------------------------------------------------------
   1 px lift on hover, back down on press; an icon inside nudges forward. */
.btn {
  transition:
    background-color var(--motion-base) ease,
    border-color var(--motion-base) ease,
    color var(--motion-base) ease,
    box-shadow var(--motion-base) ease,
    transform var(--motion-fast) var(--motion-ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: 60ms; }
.btn > svg:last-child {
  transition: transform var(--motion-fast) var(--motion-ease);
}
.btn:hover > svg:last-child { transform: translateX(2px); }

/* --- 4. Cards -------------------------------------------------------------
   Cards are not links: border and shadow only (already in home.css).
   A card that IS a link gets a 2 px lift as the cue that it is clickable. */
a.glass-card {
  transition:
    border-color var(--motion-base) ease,
    box-shadow var(--motion-base) ease,
    transform var(--motion-base) var(--motion-ease);
}
a.glass-card:hover { transform: translateY(-2px); }
.glass-card:focus-within {
  border-color: var(--accent-soft-border, #c8e1e8);
}

/* --- 5. Focus -------------------------------------------------------------
   One clear ring for keyboard users; never animated, never removed. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-primary, #0e7490);
  outline-offset: 3px;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.site-header .btn:focus-visible,
.site-footer .btn:focus-visible,
.video-frame :focus-visible {
  outline: 2px solid var(--cyan, #22d3ee);
  outline-offset: 3px;
  box-shadow: none;
}

/* --- 6. Film frame loading state -----------------------------------------
   motion.js adds .is-loading while the poster or video is still coming in.
   A slow light sweep plus a thin bar at the bottom; no spinner. */
.video-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan, #22d3ee) 45%, var(--teal, #34d399) 55%, transparent);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.video-frame.is-loading::after {
  opacity: 1;
  animation: rd-load-bar 1.8s var(--motion-ease) infinite;
}
.video-frame.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(34, 211, 238, 0.07) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: rd-load-sweep 2.4s ease-in-out infinite;
}
@keyframes rd-load-bar {
  to { transform: translateX(100%); }
}
@keyframes rd-load-sweep {
  to { transform: translateX(100%); }
}

/* --- Reduced motion: no movement at all, state still shown -------------- */
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal-stagger] > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .btn:hover,
  .btn:hover > svg:last-child,
  a.glass-card:hover {
    transform: none;
  }
  .video-frame.is-loading::before { display: none; }
  .video-frame.is-loading::after {
    animation: none;
    transform: none;
    opacity: 0.6;   /* static thin bar: "still loading" without motion */
  }
}
