/* =====================================================================
   ROUTEGUARD.LK — MOTION LAYER
   Plain CSS (no Tailwind build needed). Everything here only applies
   when <html> has the "rg-motion" class, which the small script in
   <head> adds ONLY if the visitor has not asked for reduced motion.
   Remove this file + assets/js/motion.js and the site works as before.
   ===================================================================== */

:root {
    --rg-ease: cubic-bezier(.2, .75, .2, 1);
    --rg-ease-out: cubic-bezier(.16, 1, .3, 1);
    --rg-orange: #FF5500;
    --rg-green: #059669;
    --rg-red: #DC2626;
    --rg-ink: #0F172A;
}

/* ---------- Keyframes ---------- */
@keyframes rgUp      { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes rgFade    { from { opacity: 0; } to { opacity: 1; } }
@keyframes rgPop     { 0% { opacity: 0; transform: scale(.94) translateY(10px); } 100% { opacity: 1; transform: none; } }
@keyframes rgDrop    { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes rgWipe    { from { clip-path: inset(-4px 100% -12px -4px); } to { clip-path: inset(-4px -12px -12px -4px); } }
@keyframes rgCardIn  { from { opacity: 0; transform: perspective(900px) rotateY(-14deg) translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes rgPing    { 0% { transform: scale(1); opacity: .85; } 80%, 100% { transform: scale(2.3); opacity: 0; } }
@keyframes rgPulse   { 0% { transform: scale(.75); opacity: .45; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes rgRoad    { to { stroke-dashoffset: 36; } }
@keyframes rgDash    { to { stroke-dashoffset: -32; } }
@keyframes rgDashRed { to { stroke-dashoffset: -24; } }
@keyframes rgIdle    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.6px); } }
@keyframes rgShake   {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-7px) rotate(-.3deg); }
    30% { transform: translateX(6px) rotate(.3deg); }
    45% { transform: translateX(-5px); }
    60% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}
@keyframes rgAlarmGlow {
    0%   { box-shadow: 8px 8px 0 0 var(--rg-ink), 0 0 0 0 rgba(220, 38, 38, .55); }
    50%  { box-shadow: 8px 8px 0 0 var(--rg-ink), 0 0 0 14px rgba(220, 38, 38, 0); }
    100% { box-shadow: 8px 8px 0 0 var(--rg-ink), 0 0 0 0 rgba(220, 38, 38, 0); }
}
@keyframes rgSlideIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes rgFlip    { 0% { opacity: 0; transform: rotateX(80deg); } 100% { opacity: 1; transform: none; } }
@keyframes rgBlink   { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes rgStamp   { 0% { transform: scale(2.4) rotate(-12deg); opacity: 0; } 60% { transform: scale(.92) rotate(2deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes rgBump    { 0% { transform: none; } 35% { transform: translateY(-5px) scale(1.12); color: var(--rg-orange); } 100% { transform: none; } }
@keyframes rgStripes { to { background-position: 28px 0; } }
@keyframes rgFill    { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rgCaret   { 50% { border-color: transparent; } }
@keyframes rgPaper   { 0% { opacity: 0; transform: translateY(-14px) rotate(-1.2deg); } 100% { opacity: 1; transform: none; } }
@keyframes rgPinPop  { 0% { transform: scale(0); } 70% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes rgSheen   { from { transform: translateX(-130%) skewX(-20deg); } to { transform: translateX(260%) skewX(-20deg); } }

/* ---------- Scroll progress bar ---------- */
#rgProgress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 45;
    background: linear-gradient(90deg, var(--rg-orange), #F59E0B 60%, #10B981);
    transform-origin: 0 50%; transform: scaleX(0);
    pointer-events: none;
}

/* ---------- Hero intro (plays once on load) ---------- */
.rg-motion [data-hero] { animation: rgUp .8s var(--rg-ease-out) both; }
.rg-motion [data-hero="1"] { animation-delay: .05s; }
.rg-motion [data-hero="2"] { animation-delay: .15s; }
.rg-motion [data-hero="3"] { animation-delay: .35s; }
.rg-motion [data-hero="4"] { animation-delay: .48s; }
.rg-motion [data-hero="5"] { animation-delay: .6s; }
.rg-motion [data-hero="card"] { animation: rgCardIn 1s var(--rg-ease-out) .3s both; }
.rg-motion .rg-highlight { animation: rgWipe .7s var(--rg-ease) .55s both; }
.rg-motion [data-hero="5"] > * { animation: rgUp .6s var(--rg-ease-out) both; }
.rg-motion [data-hero="5"] > *:nth-child(1) { animation-delay: .7s; }
.rg-motion [data-hero="5"] > *:nth-child(2) { animation-delay: .8s; }
.rg-motion [data-hero="5"] > *:nth-child(3) { animation-delay: .9s; }

/* Status-bar typewriter caret */
.rg-typing::after {
    content: ""; display: inline-block; width: .55em; height: 1em; margin-left: 2px;
    vertical-align: -2px; background: currentColor; animation: rgBlink .7s steps(1) infinite;
}

/* ---------- Scroll reveals ---------- */
.rg-motion [data-reveal] {
    transition: opacity .75s var(--rg-ease-out), transform .75s var(--rg-ease-out);
    transition-delay: var(--rg-delay, 0ms);
    will-change: opacity, transform;
}
.rg-motion [data-reveal]:not(.rg-in) { opacity: 0; }
.rg-motion [data-reveal="up"]:not(.rg-in)    { transform: translateY(34px); }
.rg-motion [data-reveal="left"]:not(.rg-in)  { transform: translateX(-46px); }
.rg-motion [data-reveal="right"]:not(.rg-in) { transform: translateX(46px); }
.rg-motion [data-reveal="zoom"]:not(.rg-in)  { transform: scale(.94) translateY(20px); }
.rg-motion [data-reveal="flip"]:not(.rg-in)  { transform: perspective(900px) rotateX(14deg) translateY(30px); transform-origin: 50% 100%; }

/* ---------- Hero truck diagram ---------- */
.rg-motion .rg-road { animation: rgRoad .9s linear infinite; }
.rg-motion .rg-truck { animation: rgIdle .55s ease-in-out infinite; }
.rg-motion .rg-node { cursor: pointer; outline: none; }
.rg-motion .rg-node .rg-ping {
    transform-box: fill-box; transform-origin: center;
    animation: rgPing 2.2s var(--rg-ease) infinite;
    pointer-events: none;
}
.rg-motion .rg-node > circle:not(.rg-ping) { transition: transform .2s var(--rg-ease); transform-box: fill-box; transform-origin: center; }
.rg-motion .rg-node:hover > circle:not(.rg-ping),
.rg-motion .rg-node:focus-visible > circle:not(.rg-ping),
.rg-motion .rg-node.rg-selected > circle:not(.rg-ping) { transform: scale(1.22); }
.rg-motion .rg-node:focus-visible > circle:not(.rg-ping) { stroke: var(--rg-orange); stroke-width: 4; }
.rg-motion .rg-readout-swap { animation: rgFlip .45s var(--rg-ease-out) both; transform-origin: 50% 0; }

/* ---------- Buttons: sheen + arrow nudge ---------- */
.rg-motion .btn-industrial.bg-safetyOrange { position: relative; overflow: hidden; isolation: isolate; }
.rg-motion .btn-industrial.bg-safetyOrange::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: translateX(-130%) skewX(-20deg); pointer-events: none; z-index: 1;
}
.rg-motion .btn-industrial.bg-safetyOrange:hover::after { animation: rgSheen .75s var(--rg-ease); }
.rg-motion .btn-industrial svg { transition: transform .25s var(--rg-ease); }
.rg-motion .btn-industrial:hover svg:last-child { transform: translateX(4px); }

/* Busy "scanning" / "transmitting" stripes on buttons */
.rg-motion .rg-busy {
    background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .2) 0 10px, transparent 10px 20px) !important;
    background-size: 28px 28px;
    animation: rgStripes .6s linear infinite;
    cursor: progress;
}
.rg-motion .rg-busy .rg-bar {
    position: absolute; left: 0; bottom: 0; height: 4px; width: 100%;
    background: #FFFFFF; transform-origin: 0 50%;
    animation: rgFill var(--rg-bar-ms, 900ms) linear both;
}

/* ---------- Permit scanner ---------- */
.rg-motion .rg-paper-swap { animation: rgPaper .5s var(--rg-ease-out) both; }
.rg-motion .rg-step { transition: background-color .25s, color .25s, transform .25s var(--rg-ease); }
.rg-motion .rg-step-wait { background: #F1F5F9 !important; color: #94A3B8 !important; }
.rg-motion .rg-step-run  { background: #FEF3C7 !important; color: #B45309 !important; transform: translateY(-2px); box-shadow: 2px 2px 0 var(--rg-ink); animation: rgBlink .6s ease-in-out infinite; }
.rg-motion .rg-step-done { animation: rgBump .45s var(--rg-ease); }
.rg-motion .rg-typing-box::after {
    content: ""; display: inline-block; width: 7px; height: 13px; vertical-align: -2px;
    background: #34D399; margin-left: 1px; animation: rgBlink .5s steps(1) infinite;
}
.rg-motion #extWaypoints > * { animation: rgPop .4s var(--rg-ease-out) both; }
.rg-motion .rg-pin { transform-box: fill-box; transform-origin: center; animation: rgPinPop .45s var(--rg-ease-out) both; }
.rg-motion .rg-stamp { display: inline-block; animation: rgStamp .55s var(--rg-ease-out) both; }
.rg-motion .rg-flash { animation: rgBump .5s var(--rg-ease); display: block; }

/* ---------- Live route simulator ---------- */
.rg-motion #permittedPath { animation: rgDash 1.1s linear infinite; }
.rg-motion #simTruckPulse { transform-box: fill-box; transform-origin: center; animation: rgPulse 1.8s ease-out infinite; }
.rg-motion .rg-breach #simTruckPulse { animation-duration: .7s; }
.rg-motion .rg-breach #unauthorizedPath { opacity: 1; stroke-width: 5; animation: rgDashRed .5s linear infinite; }
.rg-motion .rg-alarm { animation: rgShake .55s var(--rg-ease), rgAlarmGlow 1s ease-out 2; }
.rg-motion .rg-alert-in { animation: rgSlideIn .5s var(--rg-ease-out) both; }
.rg-motion .rg-metric-in { display: inline-block; animation: rgFlip .4s var(--rg-ease-out) both; transform-origin: 50% 0; }
.rg-motion .rg-siren { animation: rgBlink .5s steps(1) infinite; }
.rg-motion #ownerActionFeedback:not(.hidden) { animation: rgSlideIn .4s var(--rg-ease-out) both; }

/* ---------- Tilt cards (hardware, team, hero) ---------- */
.rg-motion .rg-tilt { transition: transform .35s var(--rg-ease), box-shadow .25s ease; transform-style: preserve-3d; }
.rg-motion .rg-tilt.rg-tilting { transition: transform .08s linear, box-shadow .25s ease; }
.rg-motion .rg-tilt.rg-tilt-glow:hover { box-shadow: 8px 8px 0 0 var(--rg-orange) !important; }
.rg-motion .rg-tilt .w-12.h-12 { transition: transform .35s var(--rg-ease); }
.rg-motion .rg-tilt:hover .w-12.h-12 { transform: translateZ(30px) rotate(-6deg) scale(1.08); }

/* ---------- Pilot form ---------- */
.rg-motion #pilotSignupForm input:not([type=checkbox]),
.rg-motion #pilotSignupForm select { transition: box-shadow .2s ease, transform .2s var(--rg-ease), background-color .2s; }
.rg-motion #pilotSignupForm input:not([type=checkbox]):focus,
.rg-motion #pilotSignupForm select:focus { box-shadow: 4px 4px 0 0 var(--rg-orange); transform: translate(-2px, -2px); }
.rg-motion #pilotSuccessBox:not(.hidden) { animation: rgPop .5s var(--rg-ease-out) both; }
.rg-motion #pilotSuccessBox:not(.hidden) .bg-permitGreen { display: inline-block; animation: rgStamp .6s var(--rg-ease-out) .15s both; }
.rg-motion .rg-bump { display: inline-block; animation: rgBump .6s var(--rg-ease); }

/* ---------- Modals & mobile menu ---------- */
.rg-motion #privacyModal:not(.hidden),
.rg-motion #analyticsModal:not(.hidden) { animation: rgFade .2s ease both; }
.rg-motion #privacyModal:not(.hidden) > .industrial-card,
.rg-motion #analyticsModal:not(.hidden) > .industrial-card { animation: rgPop .35s var(--rg-ease-out) both; }
.rg-motion #recentSignupsList > * { animation: rgSlideIn .4s var(--rg-ease-out) both; }
.rg-motion #recentSignupsList > *:nth-child(2) { animation-delay: .06s; }
.rg-motion #recentSignupsList > *:nth-child(3) { animation-delay: .12s; }
.rg-motion #recentSignupsList > *:nth-child(n+4) { animation-delay: .18s; }
.rg-motion #mobileMenu:not(.hidden) { animation: rgDrop .25s var(--rg-ease-out) both; }
.rg-motion #mobileMenu:not(.hidden) > a { animation: rgDrop .3s var(--rg-ease-out) both; }
.rg-motion #mobileMenu:not(.hidden) > a:nth-child(2) { animation-delay: .04s; }
.rg-motion #mobileMenu:not(.hidden) > a:nth-child(3) { animation-delay: .08s; }
.rg-motion #mobileMenu:not(.hidden) > a:nth-child(4) { animation-delay: .12s; }
.rg-motion #mobileMenu:not(.hidden) > a:nth-child(5) { animation-delay: .16s; }
.rg-motion #mobileMenu:not(.hidden) > a:nth-child(6) { animation-delay: .2s; }

/* Safety net: if the visitor's OS asks for reduced motion, stop everything. */
@media (prefers-reduced-motion: reduce) {
    .rg-motion *, .rg-motion *::before, .rg-motion *::after {
        animation: none !important; transition: none !important;
    }
    .rg-motion [data-reveal] { opacity: 1 !important; transform: none !important; }
    #rgProgress { display: none; }
}
