/* ============================================
   INTERACTIVE EFFECTS - Smiggy Digital Grid
   Konami, Cursor Trail, Click Ripples, 
   Typewriter, Glitch, Terminal, Leaderboard,
   Daily Challenge, Quotes
   ============================================ */

/* ---- Custom Tron Cursor ---- */
body.tron-cursor {
    cursor: none;
}

.tron-cursor a,
.tron-cursor button,
.tron-cursor input,
.tron-cursor [role="button"] {
    cursor: none;
}

#customCursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 100000;
    transition: transform 0.1s ease, border-color 0.2s ease;
    box-shadow: 0 0 10px rgba(255, 0, 64, 0.6), inset 0 0 6px rgba(255, 0, 64, 0.3);
    mix-blend-mode: screen;
}

#customCursor.clicking {
    transform: scale(0.6);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(255, 0, 128, 0.8), inset 0 0 10px rgba(255, 0, 128, 0.4);
}

.cursor-trail {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 99999;
    background: var(--primary-color);
    box-shadow: 0 0 8px rgba(255, 0, 64, 0.8);
    opacity: 0.8;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.cursor-trail.fade {
    opacity: 0;
    transform: scale(0);
}

/* ---- Click Ripple Effect ---- */
.click-ripple {
    position: fixed;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    pointer-events: none;
    z-index: 99998;
    animation: ripple-expand 0.6s ease-out forwards;
}

@keyframes ripple-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    100% {
        width: 120px;
        height: 120px;
        opacity: 0;
        transform: translate(-50%, -50%);
    }
}

.click-ripple-inner {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 0, 64, 0.3) 0%, transparent 70%);
    pointer-events: none;
    z-index: 99997;
    animation: ripple-inner-expand 0.5s ease-out forwards;
}

@keyframes ripple-inner-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
        transform: translate(-50%, -50%);
    }
    100% {
        width: 80px;
        height: 80px;
        opacity: 0;
        transform: translate(-50%, -50%);
    }
}

/* ---- Hero Typewriter ---- */
.hero-title .typewriter-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background: var(--primary-color);
    margin-left: 4px;
    animation: blink-cursor 0.7s step-end infinite;
    vertical-align: text-bottom;
    box-shadow: 0 0 8px rgba(255, 0, 64, 0.8);
}

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

/* ---- Glitch Effect on Section Titles ---- */
.section-title.glitch-active {
    animation: glitch-text 0.4s ease-in-out;
}

@keyframes glitch-text {
    0% { transform: translate(0); text-shadow: var(--glow-primary); }
    10% { transform: translate(-3px, 2px); text-shadow: 3px 0 #ff0080, -3px 0 #00ffff; }
    20% { transform: translate(3px, -1px); text-shadow: -3px 0 #ff0040, 3px 0 #ff0080; }
    30% { transform: translate(0, 2px); clip-path: inset(40% 0 30% 0); }
    40% { transform: translate(-2px, -2px); clip-path: inset(20% 0 50% 0); }
    50% { transform: translate(2px, 1px); clip-path: inset(60% 0 10% 0); }
    60% { transform: translate(-1px, 0); clip-path: none; }
    70% { transform: translate(0); text-shadow: var(--glow-primary); }
    100% { transform: translate(0); text-shadow: var(--glow-primary); }
}

/* ---- Konami Code Secret Mode ---- */
.konami-flash {
    position: fixed;
    inset: 0;
    background: var(--primary-color);
    z-index: 999999;
    pointer-events: none;
    animation: konami-flash-anim 0.8s ease-out forwards;
}

@keyframes konami-flash-anim {
    0% { opacity: 0.8; }
    30% { opacity: 0; }
    50% { opacity: 0.4; }
    100% { opacity: 0; }
}

.konami-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 1000000;
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 0 0 30px rgba(255, 0, 64, 0.8), 0 0 60px rgba(255, 0, 64, 0.4);
    text-align: center;
    pointer-events: none;
    animation: konami-banner-anim 2.5s ease-out forwards;
    white-space: nowrap;
}

.konami-banner span {
    display: block;
    font-size: 1rem;
    color: var(--accent-color);
    margin-top: 0.5rem;
    letter-spacing: 3px;
}

@keyframes konami-banner-anim {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

body.konami-mode {
    --primary-color: #00ffff;
    --accent-color: #ff00ff;
    --glow-primary: 0 0 20px #00ffff;
    --glow-accent: 0 0 20px #ff00ff;
}

body.konami-mode .particle {
    background: rgba(0, 255, 255, 0.6) !important;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.8) !important;
}

/* ---- Interactive Terminal ---- */
.grid-terminal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    font-family: 'Share Tech Mono', monospace;
}

.grid-terminal.open {
    transform: translateY(0);
}

.grid-terminal-bar {
    background: rgba(0, 0, 0, 0.95);
    border-top: 2px solid var(--primary-color);
    box-shadow: 0 -4px 30px rgba(255, 0, 64, 0.3);
}

.grid-terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(255, 0, 64, 0.3);
    background: rgba(255, 0, 64, 0.05);
}

.grid-terminal-header span {
    color: var(--primary-color);
    font-size: 0.85rem;
    letter-spacing: 2px;
}

.grid-terminal-close {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.grid-terminal-close:hover {
    background: var(--primary-color);
    color: #000;
}

.grid-terminal-output {
    max-height: 250px;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-dim);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.grid-terminal-output::-webkit-scrollbar {
    width: 4px;
}

.grid-terminal-output::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.grid-terminal-output .term-line {
    margin: 0.15rem 0;
}

.grid-terminal-output .term-line.cmd {
    color: var(--primary-color);
}

.grid-terminal-output .term-line.result {
    color: var(--text-light);
}

.grid-terminal-output .term-line.error {
    color: #ff4444;
}

.grid-terminal-output .term-line.success {
    color: #44ff44;
}

.grid-terminal-output .term-line.accent {
    color: var(--accent-color);
}

.grid-terminal-output .term-ascii {
    color: var(--primary-color);
    white-space: pre;
    font-size: 0.7rem;
    line-height: 1.1;
}

.grid-terminal-input-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-top: 1px solid rgba(255, 0, 64, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

.grid-terminal-input-row .prompt {
    color: var(--primary-color);
    margin-right: 0.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.grid-terminal-input-row input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-light);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    caret-color: var(--primary-color);
}

.terminal-toggle-btn {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.3);
    letter-spacing: 1px;
}

.terminal-toggle-btn:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 25px rgba(255, 0, 64, 0.6);
}

.terminal-toggle-btn .hotkey {
    font-size: 0.65rem;
    opacity: 0.6;
    display: block;
    margin-top: 2px;
}

/* Matrix Rain Canvas */
#matrixCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#matrixCanvas.active {
    opacity: 1;
    pointer-events: auto;
}

/* ---- Transmission Intercept (Random Quote Widget) ---- */
.transmission-intercept {
    position: fixed;
    top: 5rem;
    right: -400px;
    width: 340px;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid var(--primary-color);
    border-right: none;
    border-radius: 12px 0 0 12px;
    padding: 1.25rem;
    font-family: 'Share Tech Mono', monospace;
    transition: right 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -4px 0 30px rgba(255, 0, 64, 0.3);
}

.transmission-intercept.visible {
    right: 0;
}

.transmission-intercept-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.transmission-intercept-header span {
    color: var(--primary-color);
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.transmission-intercept-close {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.transmission-intercept-body {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.transmission-intercept-source {
    color: var(--accent-color);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.transmission-intercept-trigger {
    position: fixed;
    top: 5rem;
    right: 0;
    z-index: 9997;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--primary-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--primary-color);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    padding: 0.5rem 0.4rem;
    cursor: pointer;
    writing-mode: vertical-rl;
    letter-spacing: 2px;
    transition: all 0.3s ease;
}

.transmission-intercept-trigger:hover {
    background: var(--primary-color);
    color: #000;
    padding-right: 0.6rem;
}

/* ---- Leaderboard Styles ---- */
.leaderboard-section {
    margin-top: 2rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Share Tech Mono', monospace;
}

.leaderboard-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    font-size: 0.85rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.leaderboard-table td {
    padding: 0.6rem 1rem;
    color: var(--text-light);
    border-bottom: 1px solid rgba(255, 0, 64, 0.15);
    font-size: 0.9rem;
}

.leaderboard-table tr:hover td {
    background: rgba(255, 0, 64, 0.05);
}

.leaderboard-table .rank-1 td {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.leaderboard-table .rank-2 td {
    color: #c0c0c0;
}

.leaderboard-table .rank-3 td {
    color: #cd7f32;
}

.leaderboard-initials-input {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    text-align: center;
    width: 80px;
    padding: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    border-radius: 4px;
}

.leaderboard-initials-input:focus {
    outline: none;
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.5);
}

/* ---- Leaderboard Section Spacing ---- */
.leaderboard-section-title-spaced {
    margin-top: 3rem;
}

.change-initials-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    margin-left: 0.5rem;
}

/* ---- Daily Challenge ---- */
.daily-challenge-banner {
    background: linear-gradient(135deg, rgba(255, 0, 64, 0.15) 0%, rgba(255, 0, 128, 0.1) 100%);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.daily-challenge-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(255, 0, 64, 0.1), transparent);
    animation: rotate 8s linear infinite;
    pointer-events: none;
}

.daily-challenge-banner h3 {
    font-family: 'Orbitron', monospace;
    color: var(--primary-color);
    text-shadow: var(--glow-primary);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    position: relative;
}

.daily-challenge-banner p {
    color: var(--text-dim);
    font-size: 0.9rem;
    position: relative;
}

.daily-challenge-banner .challenge-game {
    color: var(--accent-color);
    font-family: 'Orbitron', monospace;
    font-weight: 700;
}

.daily-challenge-banner .challenge-timer {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    letter-spacing: 1px;
}

/* ---- Nav Sound Indicator ---- */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    transition: width 0.3s ease, left 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
    left: 0;
}

/* ---- Mobile adjustments ---- */
@media (max-width: 768px) {
    #customCursor,
    .cursor-trail {
        display: none !important;
    }
    
    body.tron-cursor {
        cursor: auto;
    }
    
    .tron-cursor a,
    .tron-cursor button,
    .tron-cursor input {
        cursor: auto;
    }
    
    .terminal-toggle-btn {
        bottom: 0.5rem;
        left: 0.5rem;
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }
    
    .grid-terminal-output {
        max-height: 180px;
    }
    
    .transmission-intercept {
        width: 280px;
    }
    
    .konami-banner {
        font-size: 1.5rem;
    }
    
    .daily-challenge-banner {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .transmission-intercept {
        width: 240px;
    }
}
