/**
 * RIVERMAN RESPONSE - TACTICAL ANIMATIONS
 * Call of Duty-Inspired Effects & Transitions
 */

/* ============================================
   GLITCH TEXT EFFECT
   ============================================ */
.glitch {
    position: relative;
    font-family: var(--font-stencil);
    letter-spacing: 0.1em;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-deep);
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--color-danger);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--color-secondary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
    animation-delay: -1s;
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); transform: skew(0.5deg); }
    5% { clip: rect(70px, 9999px, 71px, 0); transform: skew(0.2deg); }
    10% { clip: rect(29px, 9999px, 24px, 0); transform: skew(0.8deg); }
    15% { clip: rect(46px, 9999px, 86px, 0); transform: skew(0.1deg); }
    20% { clip: rect(95px, 9999px, 40px, 0); transform: skew(0.3deg); }
    25% { clip: rect(14px, 9999px, 65px, 0); transform: skew(0.9deg); }
    30% { clip: rect(72px, 9999px, 33px, 0); transform: skew(0.4deg); }
    35% { clip: rect(52px, 9999px, 75px, 0); transform: skew(0.2deg); }
    40% { clip: rect(83px, 9999px, 42px, 0); transform: skew(0.6deg); }
    45% { clip: rect(19px, 9999px, 89px, 0); transform: skew(0.3deg); }
    50% { clip: rect(36px, 9999px, 51px, 0); transform: skew(0.7deg); }
    55% { clip: rect(67px, 9999px, 28px, 0); transform: skew(0.1deg); }
    60% { clip: rect(45px, 9999px, 77px, 0); transform: skew(0.5deg); }
    65% { clip: rect(88px, 9999px, 16px, 0); transform: skew(0.2deg); }
    70% { clip: rect(23px, 9999px, 63px, 0); transform: skew(0.8deg); }
    75% { clip: rect(58px, 9999px, 39px, 0); transform: skew(0.4deg); }
    80% { clip: rect(11px, 9999px, 82px, 0); transform: skew(0.6deg); }
    85% { clip: rect(74px, 9999px, 47px, 0); transform: skew(0.3deg); }
    90% { clip: rect(39px, 9999px, 91px, 0); transform: skew(0.1deg); }
    95% { clip: rect(61px, 9999px, 22px, 0); transform: skew(0.7deg); }
    100% { clip: rect(48px, 9999px, 68px, 0); transform: skew(0.5deg); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(65px, 9999px, 119px, 0); transform: skew(0.6deg); }
    5% { clip: rect(52px, 9999px, 32px, 0); transform: skew(0.3deg); }
    10% { clip: rect(79px, 9999px, 88px, 0); transform: skew(0.9deg); }
    15% { clip: rect(13px, 9999px, 53px, 0); transform: skew(0.2deg); }
    20% { clip: rect(91px, 9999px, 21px, 0); transform: skew(0.5deg); }
    25% { clip: rect(38px, 9999px, 74px, 0); transform: skew(0.8deg); }
    30% { clip: rect(27px, 9999px, 97px, 0); transform: skew(0.1deg); }
    35% { clip: rect(84px, 9999px, 45px, 0); transform: skew(0.7deg); }
    40% { clip: rect(16px, 9999px, 66px, 0); transform: skew(0.4deg); }
    45% { clip: rect(73px, 9999px, 12px, 0); transform: skew(0.6deg); }
    50% { clip: rect(42px, 9999px, 81px, 0); transform: skew(0.2deg); }
    55% { clip: rect(95px, 9999px, 37px, 0); transform: skew(0.5deg); }
    60% { clip: rect(24px, 9999px, 59px, 0); transform: skew(0.9deg); }
    65% { clip: rect(68px, 9999px, 93px, 0); transform: skew(0.3deg); }
    70% { clip: rect(51px, 9999px, 26px, 0); transform: skew(0.7deg); }
    75% { clip: rect(86px, 9999px, 62px, 0); transform: skew(0.1deg); }
    80% { clip: rect(19px, 9999px, 78px, 0); transform: skew(0.8deg); }
    85% { clip: rect(57px, 9999px, 41px, 0); transform: skew(0.4deg); }
    90% { clip: rect(82px, 9999px, 15px, 0); transform: skew(0.6deg); }
    95% { clip: rect(34px, 9999px, 89px, 0); transform: skew(0.2deg); }
    100% { clip: rect(76px, 9999px, 54px, 0); transform: skew(0.5deg); }
}

/* Subtle Glitch - Less Intense */
.glitch-subtle::before,
.glitch-subtle::after {
    animation-duration: 10s;
    opacity: 0.8;
}

/* ============================================
   TACTICAL LOADING ANIMATION
   ============================================ */
.loader-tactical {
    width: 60px;
    height: 60px;
    position: relative;
}

.loader-tactical::before,
.loader-tactical::after {
    content: '';
    position: absolute;
    border: 3px solid transparent;
    border-radius: 50%;
}

.loader-tactical::before {
    inset: 0;
    border-top-color: var(--color-primary);
    border-right-color: var(--color-primary);
    animation: loader-spin 1.5s linear infinite;
}

.loader-tactical::after {
    inset: 8px;
    border-bottom-color: var(--color-secondary);
    border-left-color: var(--color-secondary);
    animation: loader-spin 1s linear infinite reverse;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

/* Bar Loader */
.loader-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-medium);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loader-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    animation: loader-bar-slide 1.5s infinite;
}

@keyframes loader-bar-slide {
    to { left: 100%; }
}

/* Dots Loader */
.loader-dots {
    display: flex;
    gap: 8px;
}

.loader-dots span {
    width: 10px;
    height: 10px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: loader-dots-bounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }
.loader-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loader-dots-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   SCANNING EFFECT
   ============================================ */
.scan-effect {
    position: relative;
    overflow: hidden;
}

.scan-effect::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(0, 240, 255, 0.1) 50%,
        transparent 100%
    );
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0% { top: -50%; }
    100% { top: 150%; }
}

/* ============================================
   PULSE EFFECTS
   ============================================ */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-primary-glow);
    }
    50% {
        box-shadow: 0 0 20px var(--color-primary-glow),
                    0 0 40px var(--color-primary-glow);
    }
}

.blink {
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Status Indicator */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-indicator::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: status-ping 1.5s ease-out infinite;
}

.status-online {
    background: var(--color-success);
    color: var(--color-success);
}

.status-offline {
    background: var(--color-danger);
    color: var(--color-danger);
}

.status-away {
    background: var(--color-warning);
    color: var(--color-warning);
}

@keyframes status-ping {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ============================================
   ENTRANCE ANIMATIONS
   ============================================ */
.fade-in {
    /* 'both' (was 'forwards'): during an animation-delay introduced by a
       .stagger-* class the element must already be hidden. With 'forwards'
       it painted fully visible for the whole delay and then snapped to
       opacity:0 — the dashboard announcements/events panels appeared to
       "reload" ~0.5s after the page rendered. */
    animation: fadeIn 0.5s ease-out both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-down {
    animation: fadeInDown 0.5s ease-out both;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.4s ease-out both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out both;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Staggered Animation Delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }
/* 7/8 were referenced by views (dashboard training cards) but never defined,
   silently collapsing their intended stagger. */
.stagger-7 { animation-delay: 0.7s; }
.stagger-8 { animation-delay: 0.8s; }

/* ============================================
   TACTICAL TYPING EFFECT
   ============================================ */
.typing {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation:
        typing 3.5s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--color-primary); }
}

/* ============================================
   TACTICAL DATA STREAM
   ============================================ */
.data-stream {
    position: relative;
    overflow: hidden;
}

.data-stream::before {
    content: '01001010 10110101 00101011 11010010 01011010 10101101';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(0, 240, 255, 0.1);
    animation: data-scroll 20s linear infinite;
    white-space: nowrap;
    pointer-events: none;
}

@keyframes data-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* ============================================
   HUD ANIMATION EFFECTS
   ============================================ */
.hud-flicker {
    animation: hud-flicker 0.15s infinite;
}

@keyframes hud-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.hud-scan-line {
    position: relative;
    overflow: hidden;
}

.hud-scan-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--color-secondary),
        transparent
    );
    animation: hud-scan 2s ease-in-out infinite;
}

@keyframes hud-scan {
    0%, 100% { top: 0; opacity: 0; }
    50% { opacity: 1; }
    100% { top: 100%; }
}

/* ============================================
   TACTICAL REVEAL
   ============================================ */
.reveal-tactical {
    position: relative;
    overflow: hidden;
}

.reveal-tactical::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    transform: translateX(-101%);
    animation: reveal 0.8s ease-out forwards;
}

.reveal-tactical > * {
    opacity: 0;
    animation: reveal-content 0.5s ease-out 0.4s forwards;
}

@keyframes reveal {
    0% { transform: translateX(-101%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(101%); }
}

@keyframes reveal-content {
    to { opacity: 1; }
}

/* ============================================
   MILITARY COUNTDOWN
   ============================================ */
.countdown-digit {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    background: var(--bg-dark);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.countdown-digit::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-dark);
}

/* ============================================
   NOTIFICATION ANIMATIONS
   ============================================ */
.notification-slide-in {
    animation: notification-slide 0.4s ease-out forwards;
}

@keyframes notification-slide {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ============================================
   BUTTON TACTICAL EFFECTS
   ============================================ */
.btn-tactical-hover:hover {
    animation: btn-tactical 0.3s ease-out;
}

@keyframes btn-tactical {
    0% {
        box-shadow: 0 0 0 0 var(--color-primary-glow);
    }
    50% {
        box-shadow: 0 0 20px 10px var(--color-primary-glow);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

/* ============================================
   PAGE TRANSITION
   ============================================ */
.page-transition {
    position: fixed;
    inset: 0;
    background: var(--bg-deepest);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: page-transition-out 0.5s ease-out 0.3s forwards;
}

@keyframes page-transition-out {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* ============================================
   HEXAGON ELEMENTS
   ============================================ */
.hexagon {
    width: 60px;
    height: 34.64px;
    background: var(--color-primary);
    position: relative;
    margin: 17.32px 0;
}

.hexagon::before,
.hexagon::after {
    content: '';
    position: absolute;
    width: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
}

.hexagon::before {
    bottom: 100%;
    border-bottom: 17.32px solid var(--color-primary);
}

.hexagon::after {
    top: 100%;
    border-top: 17.32px solid var(--color-primary);
}

/* ============================================
   RADAR SWEEP
   ============================================ */
.radar {
    width: 100px;
    height: 100px;
    border: 2px solid var(--color-secondary);
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

.radar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 2px;
    background: var(--color-secondary);
    transform-origin: left center;
    animation: radar-sweep 2s linear infinite;
}

.radar::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 240, 255, 0.3)
    );
    transform-origin: left top;
    animation: radar-sweep 2s linear infinite;
}

@keyframes radar-sweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   PARTICLE SYSTEM (CSS-only basics)
   ============================================ */
.particles-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--color-secondary);
    border-radius: 50%;
    opacity: 0.3;
    animation: particle-float 20s linear infinite;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Grid Background Animation */
.grid-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
        linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 20s linear infinite;
}

@keyframes grid-move {
    from { background-position: 0 0; }
    to { background-position: 50px 50px; }
}
