/* ========================================
   LESSON ANIMATION LIBRARY
   ========================================
   
   This file contains reusable animations for lesson content.
   To add new animations:
   1. Add CSS to appropriate section below
   2. Document in Animation Gallery (/super-admin/animation-gallery)
   3. Follow naming convention: .lesson-content .animation-name
   
   ======================================== */

/* ========================================
   TRAFFIC SIGNALS
   ======================================== */

/* Traffic Light - Generic Container */
.lesson-content .traffic-light {
    width: 120px;
    height: 320px;
    background: #000;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0 10px #333;
    margin: 40px auto;
}

.lesson-content .traffic-light .light {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #222;
}

/* Red Light (Stop) */
.lesson-content .traffic-light .light.red {
    background: #ff0000;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
    animation: flash 1s infinite;
}

/* Yellow Light (Caution) */
.lesson-content .traffic-light .light.yellow {
    background: #ffcc00;
    box-shadow: 0 0 30px rgba(255, 255, 0, 0.7);
    animation: flash 1s infinite;
}

/* Green Light (Go) */
.lesson-content .traffic-light .light.green {
    background: #00ff00;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.7);
    animation: flash 1s infinite;
}

/* Compact Traffic Light (floats right alongside text) */
.lesson-content .traffic-light-sm,
.lv-body .traffic-light-sm {
    width: 70px;
    height: 190px;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    float: right;
    margin: 0 0 12px 16px;
}
.lesson-content .traffic-light-sm .light,
.lv-body .traffic-light-sm .light {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #222;
    /* Subtle visible ring so each housing is distinguishable */
    box-shadow: 0 0 0 2px #2e2e2e, 0 0 0 3px #1a1a1a;
}
.lesson-content .traffic-light-sm .light.red-flash,
.lv-body .traffic-light-sm .light.red-flash {
    background: radial-gradient(circle at 40% 40%, #ff6060, #E60000 50%, #990000);
    box-shadow: 0 0 18px rgba(230, 0, 0, 0.8), inset 0 0 10px rgba(255,100,100,0.3);
    animation: flash 1s infinite;
}
@media (max-width: 576px) {
    .lesson-content .traffic-light-sm,
    .lv-body .traffic-light-sm {
        float: none !important;
        margin: 0 auto 12px auto !important;
    }
}

/* Yellow Light (flashing) inside compact traffic light */
.lesson-content .traffic-light-sm .light.yellow-flash,
.lv-body .traffic-light-sm .light.yellow-flash {
    background: radial-gradient(circle at 40% 40%, #fff5a0, #EFB700 50%, #b38900);
    box-shadow: 0 0 18px rgba(239, 183, 0, 0.8), inset 0 0 10px rgba(255,255,200,0.3);
    animation: flash 1s infinite;
}

/* Yellow Arrow — dark housing, separate chevron + tail (46px circle) */
.lesson-content .traffic-light-sm .light.yellow-arrow-flash,
.lv-body .traffic-light-sm .light.yellow-arrow-flash {
    background: #1a1a1a;
    box-shadow: 0 0 0 2px #2e2e2e, 0 0 0 3px #1a1a1a;
    position: relative;
}
/* Chevron head: left:3px w:13px h:26px (80% of 32) */
.lesson-content .traffic-light-sm .light.yellow-arrow-flash::before,
.lv-body .traffic-light-sm .light.yellow-arrow-flash::before {
    content: '';
    position: absolute;
    width: 13px; height: 26px;
    left: 3px; top: 10px;
    background: #EFB700;
    clip-path: polygon(100% 0%, 0% 50%, 100% 100%, 100% 70%, 50% 50%, 100% 30%);
    animation: flash-arrow-bg-yellow 1s infinite;
}
/* Tail: left:20px w:20px h:6px (80% of 8) */
.lesson-content .traffic-light-sm .light.yellow-arrow-flash::after,
.lv-body .traffic-light-sm .light.yellow-arrow-flash::after {
    content: '';
    position: absolute;
    width: 20px; height: 6px;
    left: 20px; top: 20px;
    background: #EFB700;
    animation: flash-arrow-bg-yellow 1s infinite;
}

/* Red Arrow — dark housing, separate chevron + tail (46px circle) */
.lesson-content .traffic-light-sm .light.red-arrow-flash,
.lv-body .traffic-light-sm .light.red-arrow-flash {
    background: #1a1a1a;
    box-shadow: 0 0 0 2px #2e2e2e, 0 0 0 3px #1a1a1a;
    position: relative;
}
/* Chevron head: h:26px (80% of 32) */
.lesson-content .traffic-light-sm .light.red-arrow-flash::before,
.lv-body .traffic-light-sm .light.red-arrow-flash::before {
    content: '';
    position: absolute;
    width: 13px; height: 26px;
    left: 3px; top: 10px;
    background: #E60000;
    clip-path: polygon(100% 0%, 0% 50%, 100% 100%, 100% 70%, 50% 50%, 100% 30%);
    animation: flash-arrow-bg-red 1s infinite;
}
/* Tail: h:6px (80% of 8) */
.lesson-content .traffic-light-sm .light.red-arrow-flash::after,
.lv-body .traffic-light-sm .light.red-arrow-flash::after {
    content: '';
    position: absolute;
    width: 20px; height: 6px;
    left: 20px; top: 20px;
    background: #E60000;
    animation: flash-arrow-bg-red 1s infinite;
}

/* Green Light (steady) inside compact traffic light */
.lesson-content .traffic-light-sm .light.green-solid,
.lv-body .traffic-light-sm .light.green-solid {
    background: radial-gradient(circle at 40% 40%, #90ff90, #00c800 50%, #008800);
    box-shadow: 0 0 18px rgba(0, 200, 0, 0.8), inset 0 0 10px rgba(144,255,144,0.3);
}

/* Green Arrow (steady) inside compact traffic light */
.lesson-content .traffic-light-sm .light.green-arrow-solid,
.lv-body .traffic-light-sm .light.green-arrow-solid {
    background: radial-gradient(circle at 40% 40%, #90ff90, #00c800 50%, #008800);
    box-shadow: 0 0 18px rgba(0, 200, 0, 0.8), inset 0 0 10px rgba(144,255,144,0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lesson-content .traffic-light-sm .light.green-arrow-solid::before,
.lv-body .traffic-light-sm .light.green-arrow-solid::before {
    content: '';
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 14px solid #fff;
    position: absolute;
    left: 3px;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.8));
}
.lesson-content .traffic-light-sm .light.green-arrow-solid::after,
.lv-body .traffic-light-sm .light.green-arrow-solid::after {
    content: '';
    width: 20px;
    height: 6px;
    background: #fff;
    position: absolute;
    left: 15px;
    border-radius: 0 2px 2px 0;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.8));
}

/* ========================================
   LANE USE SIGNALS (square overhead signals)
   ======================================== */
.lesson-content .lane-signal,
.lv-body .lane-signal {
    width: 64px;
    height: 64px;
    background: #1a1a1a;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    flex-shrink: 0;
    padding: 4px;
}
.lesson-content .lane-signal .signal-circle,
.lv-body .lane-signal .signal-circle {
    width: 52px;
    height: 52px;
    background: #000;
    border-radius: 50%;
    border: 2px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lane-signal-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}
.lane-signal-row .lane-signals-group {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    order: 2;
}
.lane-signal-row p {
    margin: 0;
    flex: 1;
    padding-top: 4px;
    order: 1;
}

.lane-signal-row .lane-signal svg {
    width: 36px;
    height: 36px;
}

.lane-signal-img {
    width: 68px;
    height: auto;
    border-radius: 6px;
    flex-shrink: 0;
    display: block;
}

@media (max-width: 768px) {
    .lane-signal-row {
        flex-direction: column;
    }
    .lane-signal-row .lane-signals-group {
        order: 2;
    }
    .lane-signal-row p {
        order: 1;
    }
}

@media (max-width: 576px) {
    .lesson-content .lane-signal,
    .lv-body .lane-signal {
        width: 54px;
        height: 54px;
    }
    .lesson-content .lane-signal .signal-circle,
    .lv-body .lane-signal .signal-circle {
        width: 44px;
        height: 44px;
    }
    .lane-signal-row .lane-signal svg {
        width: 28px;
        height: 28px;
    }
}

/* ========================================
   ROAD SIGNS
   ======================================== */

/* Stop Sign */
.lesson-content .stop-sign {
    width: 150px;
    height: 150px;
    background: #ff0000;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px auto;
    border: 8px solid white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transform: rotate(45deg);
}

.lesson-content .stop-sign .text {
    transform: rotate(-45deg);
}

/* Yield Sign */
.lesson-content .yield-sign {
    width: 0;
    height: 0;
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-bottom: 173px solid #ffcc00;
    position: relative;
    margin: 50px auto;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

/* Warning Sign (Diamond) */
.lesson-content .warning-sign {
    width: 150px;
    height: 150px;
    background: #ffcc00;
    color: #000;
    font-size: 3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
    border: 6px solid #000;
    transform: rotate(45deg);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.lesson-content .warning-sign .icon {
    transform: rotate(-45deg);
}

/* ========================================
   ANIMATED ICONS
   ======================================== */

/* Pulsing Alert */
.lesson-content .pulse-alert {
    display: inline-block;
    padding: 15px 30px;
    background: #ff6b6b;
    color: white;
    border-radius: 10px;
    font-weight: bold;
    margin: 20px auto;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

/* Bouncing Arrow */
.lesson-content .bounce-arrow {
    display: inline-block;
    font-size: 3rem;
    animation: bounce 1.5s ease-in-out infinite;
}

/* Rotating Attention Icon */
.lesson-content .rotate-attention {
    display: inline-block;
    font-size: 3rem;
    color: #ff6b6b;
    animation: rotate-gentle 3s linear infinite;
}

/* Shaking Warning */
.lesson-content .shake-warning {
    display: inline-block;
    animation: shake 0.5s ease-in-out infinite;
}

/* ========================================
   HIGHLIGHT BOXES
   ======================================== */

/* Important Box (Pulsing Border) */
.lesson-content .box-important {
    padding: 20px;
    border: 3px solid #ff6b6b;
    border-radius: 10px;
    margin: 20px 0;
    background: #fff5f5;
    animation: pulse-border 2s ease-in-out infinite;
}

/* Key Concept Box (Sliding Highlight) */
.lesson-content .box-key-concept {
    padding: 20px;
    border-left: 5px solid #667eea;
    border-radius: 5px;
    margin: 20px 0;
    background: linear-gradient(90deg, #f0f3ff 0%, #ffffff 100%);
    position: relative;
    overflow: hidden;
}

.lesson-content .box-key-concept::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
    animation: slide-shine 3s ease-in-out infinite;
}

/* Safety Tip Box (Glowing) */
.lesson-content .box-safety {
    padding: 20px;
    border: 2px solid #ffc107;
    border-radius: 10px;
    margin: 20px 0;
    background: #fffef0;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.3);
    animation: glow-yellow 2s ease-in-out infinite;
}

/* ========================================
   SPEED & DISTANCE INDICATORS
   ======================================== */

/* Speedometer */
.lesson-content .speedometer {
    width: 200px;
    height: 200px;
    border: 10px solid #333;
    border-radius: 50%;
    position: relative;
    margin: 30px auto;
    background: radial-gradient(circle, #fff 60%, #f0f0f0 100%);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.lesson-content .speedometer .needle {
    width: 4px;
    height: 80px;
    background: #ff0000;
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(45deg);
    animation: needle-swing 2s ease-in-out infinite alternate;
}

/* Distance Marker */
.lesson-content .distance-marker {
    display: inline-block;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 15px 5px;
    animation: scale-pulse 1.5s ease-in-out infinite;
}

/* ========================================
   VEHICLE ANIMATIONS
   ======================================== */

/* Moving Car */
.lesson-content .car-moving {
    width: 80px;
    height: 40px;
    background: #3498db;
    border-radius: 5px;
    position: relative;
    margin: 50px 0;
    animation: move-right 4s linear infinite;
}

.lesson-content .car-moving::before {
    content: '';
    width: 20px;
    height: 20px;
    background: #222;
    border-radius: 50%;
    position: absolute;
    bottom: -10px;
    left: 10px;
}

.lesson-content .car-moving::after {
    content: '';
    width: 20px;
    height: 20px;
    background: #222;
    border-radius: 50%;
    position: absolute;
    bottom: -10px;
    right: 10px;
}

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

/* Flash (for traffic lights) */
@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* Arrow flash — clip-path chevron shape, animate background + glow */
@keyframes flash-arrow-bg-red {
    0%,  49% { background: #E60000; filter: drop-shadow(0 0 6px rgba(230,0,0,0.9)) drop-shadow(0 0 12px rgba(230,0,0,0.5)); }
    50%, 100% { background: #2a0808; filter: none; }
}
@keyframes flash-arrow-bg-yellow {
    0%,  49% { background: #EFB700; filter: drop-shadow(0 0 6px rgba(239,183,0,0.9)) drop-shadow(0 0 12px rgba(239,183,0,0.5)); }
    50%, 100% { background: #2a1800; filter: none; }
}

/* Pulse (size change) */
@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Pulse Border */
@keyframes pulse-border {
    0%, 100% { 
        border-color: #ff6b6b;
        box-shadow: 0 0 0 rgba(255, 107, 107, 0);
    }
    50% { 
        border-color: #ff4757;
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 100% { 
        transform: translateY(0);
    }
    50% { 
        transform: translateY(-20px);
    }
}

/* Rotate (gentle) */
@keyframes rotate-gentle {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Slide Shine */
@keyframes slide-shine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* Glow Yellow */
@keyframes glow-yellow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.3);
    }
    50% { 
        box-shadow: 0 0 40px rgba(255, 193, 7, 0.6);
    }
}

/* Needle Swing */
@keyframes needle-swing {
    from { transform: translateX(-50%) rotate(-45deg); }
    to { transform: translateX(-50%) rotate(135deg); }
}

/* Scale Pulse */
@keyframes scale-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Move Right */
@keyframes move-right {
    from { transform: translateX(-100px); }
    to { transform: translateX(calc(100vw + 100px)); }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Center any animated element */
.lesson-content .anim-center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Slow animation (2x duration) */
.lesson-content .anim-slow {
    animation-duration: 2s !important;
}

/* Fast animation (0.5x duration) */
.lesson-content .anim-fast {
    animation-duration: 0.5s !important;
}

/* Pause animation on hover */
.lesson-content .anim-pause-hover:hover {
    animation-play-state: paused !important;
}

/* ========================================
   FLASHING ARROW BOARDS
   ======================================== */

.arrow-boards-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 24px 0;
    align-items: center;
}

.arrow-board {
    background: #111;
    border-radius: 12px;
    padding: 20px 28px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.arrow-board .dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2a2200;
    flex-shrink: 0;
}

.dot-on {
    background: #f0c800 !important;
    box-shadow: 0 0 8px rgba(240, 200, 0, 0.9), 0 0 18px rgba(240, 200, 0, 0.5) !important;
}

/* --- SEQUENTIAL ARROW (top board) --- */
.arrow-board-seq {
    max-width: 400px;
    width: 100%;
}

.seq-arrow {
    display: flex;
    align-items: center;
    gap: 0;
}

.seq-shaft {
    display: flex;
    align-items: center;
    gap: 10px;
}

.seq-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    margin-left: 6px;
}

.seq-head-row {
    display: flex;
    gap: 3px;
}

.arrow-board-seq .dot[data-i="1"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0s; }
.arrow-board-seq .dot[data-i="2"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.15s; }
.arrow-board-seq .dot[data-i="3"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.30s; }
.arrow-board-seq .dot[data-i="4"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.45s; }
.arrow-board-seq .dot[data-i="5"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.60s; }
.arrow-board-seq .dot[data-i="6"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.75s; }
.arrow-board-seq .dot[data-i="7"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 0.90s; }
.arrow-board-seq .dot[data-i="8"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 1.05s; }
.arrow-board-seq .dot[data-i="9"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 1.05s; }
.arrow-board-seq .dot[data-i="10"] { animation: seq-run 2s ease-in-out infinite; animation-delay: 1.05s; }

@keyframes seq-run {
    0%, 100% { background: #2a2200; box-shadow: none; }
    15%, 40% { background: #f0c800; box-shadow: 0 0 8px rgba(240,200,0,0.9), 0 0 18px rgba(240,200,0,0.5); }
}

/* --- CHEVRON ARROWS (bottom board) --- */
.arrow-board-chev {
    max-width: 400px;
    width: 100%;
    gap: 16px;
}

.chev-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.chev-row {
    display: flex;
    gap: 3px;
}

.chev-group .chev-row:nth-child(1) { padding-right: 0; }
.chev-group .chev-row:nth-child(2) { padding-right: 0; }
.chev-group .chev-row:nth-child(3) { padding-right: 0; }

.arrow-board-chev .dot {
    width: 16px;
    height: 16px;
}

.chev-group[data-c="1"] .dot { animation: chev-run 1.5s ease-in-out infinite; animation-delay: 0s; }
.chev-group[data-c="2"] .dot { animation: chev-run 1.5s ease-in-out infinite; animation-delay: 0.35s; }
.chev-group[data-c="3"] .dot { animation: chev-run 1.5s ease-in-out infinite; animation-delay: 0.70s; }

@keyframes chev-run {
    0%, 100% { background: #2a2200; box-shadow: none; }
    25%, 55% { background: #f0c800; box-shadow: 0 0 8px rgba(240,200,0,0.9), 0 0 16px rgba(240,200,0,0.5); }
}

@media (prefers-reduced-motion: reduce) {
    .arrow-board .dot {
        animation: none !important;
        background: #f0c800;
        box-shadow: 0 0 10px rgba(240, 200, 0, 0.8);
    }
}

@media (max-width: 576px) {
    .arrow-board {
        padding: 14px 18px;
    }
    .arrow-board-seq .dot {
        width: 14px;
        height: 14px;
    }
    .seq-shaft {
        gap: 7px;
    }
    .arrow-board-chev .dot {
        width: 12px;
        height: 12px;
    }
    .arrow-board-chev {
        gap: 10px;
    }
}
