/* FRASCA / The Fifth Order: CSS motion layer.
   Owns simple state transitions and scroll-driven reveals.
   Content is always visible at rest. Every effect is progressive enhancement. */

:root {
  --f-motion-feedback: 100ms;
  --f-motion-micro: 161.803ms;
  --f-motion-component: 261.803ms;
  --f-motion-arrival: 423.607ms;
  --f-motion-scene: 685.41ms;
  --f-motion-stagger: 61.803ms;
  --f-ease-arrive: cubic-bezier(0.16, 1, 0.3, 1);
  --f-ease-travel: cubic-bezier(0.65, 0, 0.35, 1);
  --f-ease-exit: cubic-bezier(0.7, 0, 0.84, 0);
  --f-motion-lift: 1.618px;
  --f-motion-arrive: 27.416px;
}

/* State transitions: hover lift, edge color, press. */
.f-lift {
  transition: transform var(--f-motion-micro) var(--f-ease-arrive),
              border-color var(--f-motion-micro) var(--f-ease-arrive),
              color var(--f-motion-micro) var(--f-ease-arrive);
}
.f-lift:hover { transform: translateY(calc(var(--f-motion-lift) * -1)); }
.f-lift:active { transform: translateY(0); transition-duration: var(--f-motion-feedback); }

/* Editorial underline that draws from the left. */
.f-draw-underline {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size var(--f-motion-component) var(--f-ease-arrive);
}
.f-draw-underline:hover, .f-draw-underline:focus-visible { background-size: 100% 1px; }

/* Scroll-driven arrival. Supported browsers animate as the element enters
   the viewport. Others show the final state immediately. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    [data-f-reveal] {
      animation: f-arrive linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 61.8%;
    }
    [data-f-reveal="rule"] { animation-name: f-rule; transform-origin: left center; }
    [data-f-reveal="fade"] { animation-name: f-fade; }
  }
}

@keyframes f-arrive {
  from { opacity: 0; transform: translateY(var(--f-motion-arrive)); }
  to { opacity: 1; transform: none; }
}
@keyframes f-fade { from { opacity: 0.382; } to { opacity: 1; } }
@keyframes f-rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* SVG stroke draw for identity and geometry, triggered by adding .is-drawn.
   Set --f-path-length on the path (pathLength="1" works too). */
.f-stroke-draw path, .f-stroke-draw rect, .f-stroke-draw circle {
  stroke-dasharray: var(--f-path-length, 1);
  stroke-dashoffset: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .f-stroke-draw:not(.is-drawn) path,
  .f-stroke-draw:not(.is-drawn) rect { stroke-dashoffset: var(--f-path-length, 1); }
  .f-stroke-draw path, .f-stroke-draw rect {
    transition: stroke-dashoffset var(--f-motion-scene) var(--f-ease-arrive);
  }
}

/* View Transitions between pages (same-origin navigation).
   The expression persists; the content travels. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: var(--f-motion-micro) var(--f-ease-exit) both f-fade-out; }
::view-transition-new(root) { animation: var(--f-motion-arrival) var(--f-ease-arrive) both f-fade; }
.f-vt-identity { view-transition-name: f-identity; }
.f-vt-hero { view-transition-name: f-hero; }
@keyframes f-fade-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .f-lift:hover { transform: none; }
  @view-transition { navigation: none; }
}
