/* Cyberpunk / Neo-Tokyo Utilities */
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
    --primary: #a855f7; /* Neon Purple */
    --secondary: #ec4899;
    --bg-dark: #050505;
    --grid-color: rgba(168, 85, 247, 0.15);
}

body {
    font-family: 'JetBrains Mono', 'Inter', monospace;
    background-color: var(--bg-dark);
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #000; 
}
::-webkit-scrollbar-thumb {
    background: #2e1065; 
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary); 
}

/* Global Background Effects */
.scanline {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, transparent 50%, rgba(168, 85, 247, 0.05) 51%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.15;
}

.vignette {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 60%, black 140%);
    pointer-events: none;
    z-index: 9998;
}

/* Moving Grid Background */
.cyber-grid {
    position: fixed;
    top: 0; left: 0; width: 200%; height: 200%;
    background-image: 
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(500px) rotateX(60deg) translateY(-100px) translateZ(-200px);
    animation: gridMove 20s linear infinite;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
}

@keyframes gridMove {
    0% { transform: perspective(500px) rotateX(60deg) translateY(0) translateZ(-200px); }
    100% { transform: perspective(500px) rotateX(60deg) translateY(40px) translateZ(-200px); }
}

/* HUD Panel Style */
.hud-panel {
    background: rgba(10, 5, 20, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.3);
    position: relative;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
    backdrop-filter: blur(10px);
}

.hud-panel::before, .hud-panel::after {
    content: '';
    position: absolute;
    width: 6px; height: 6px;
    transition: all 0.3s ease;
}

.hud-panel::before {
    top: -1px; left: -1px;
    border-top: 2px solid var(--primary);
    border-left: 2px solid var(--primary);
}

.hud-panel::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid var(--primary);
    border-right: 2px solid var(--primary);
}

.hud-panel:hover::before, .hud-panel:hover::after {
    width: 100%; height: 100%;
    opacity: 0.5;
}

/* Text Effects */
.text-shadow-sm {
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.text-glow {
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.6), 0 0 20px rgba(168, 85, 247, 0.4);
}

/* Glitch Effect */
.glitch {
    position: relative;
}
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-dark);
}
.glitch::before {
    left: 2px;
    text-shadow: -1px 0 #ec4899;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-1 2.5s infinite linear alternate-reverse;
}
.glitch::after {
    left: -2px;
    text-shadow: -1px 0 #a855f7;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% { clip: rect(20px, 9999px, 80px, 0); }
    20% { clip: rect(60px, 9999px, 10px, 0); }
    40% { clip: rect(90px, 9999px, 100px, 0); }
    60% { clip: rect(10px, 9999px, 30px, 0); }
    80% { clip: rect(70px, 9999px, 120px, 0); }
    100% { clip: rect(30px, 9999px, 50px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(10px, 9999px, 90px, 0); }
    20% { clip: rect(80px, 9999px, 20px, 0); }
    40% { clip: rect(30px, 9999px, 100px, 0); }
    60% { clip: rect(90px, 9999px, 10px, 0); }
    80% { clip: rect(50px, 9999px, 140px, 0); }
    100% { clip: rect(20px, 9999px, 60px, 0); }
}

/* Animations */
.animate-fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-scale-in {
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.animate-spin-slow {
    animation: spin 8s linear infinite;
}

/* Utilities */
.clip-polygon {
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

/* Range input styling */
input[type=range] {
    -webkit-appearance: none;
    background: transparent; 
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px; width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px; 
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px;
    cursor: pointer;
    background: #334155;
    border-radius: 2px;
}

/* Markdown & Typography Overrides */
.prose {
    max-width: none;
}
.prose code {
    background: rgba(168, 85, 247, 0.1);
    color: #d8b4fe;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}
.prose pre {
    background: rgba(10, 5, 20, 0.9) !important;
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
}
.prose pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    border: none;
}
.prose ul > li::marker {
    color: var(--primary);
}
.prose table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.9em;
}
.prose th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.1em;
}
.prose td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.prose blockquote {
    border-left-color: var(--primary);
    background: rgba(168, 85, 247, 0.05);
    padding: 1rem;
    font-style: italic;
    color: #94a3b8;
}

/* Right Panel Layout Fixes */
#plan-checklist {
    min-height: 0; /* Crucial for nested flex scrolling */
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
    /* Ensure scrollbar sits on top */
    scrollbar-gutter: stable;
}

/* Fix parent container to allow child scroll */
.right-panel-content {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Animation Definitions */
/* 1. New Item Slide In */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
.animate-slide-in-right {
    animation: slideInRight 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 2. Task Complete Flash (Green) */
@keyframes flashSuccess {
    0% { background-color: rgba(34, 197, 94, 0.6); border-color: rgba(34, 197, 94, 1); box-shadow: 0 0 30px rgba(34, 197, 94, 0.5); transform: scale(1.02); }
    100% { background-color: rgba(20, 83, 45, 0.2); border-color: rgba(34, 197, 94, 0.3); transform: scale(1); }
}
.animate-flash-success {
    animation: flashSuccess 1.5s ease-out forwards;
    z-index: 10;
}

/* 3. Follow-up/Update Flash (Purple/Blue) */
@keyframes flashUpdate {
    0% { background-color: rgba(168, 85, 247, 0.5); border-color: rgba(168, 85, 247, 1); box-shadow: 0 0 30px rgba(168, 85, 247, 0.4); }
    100% { background-color: rgba(31, 41, 55, 0.3); border-color: rgba(75, 85, 99, 0.3); }
}
.animate-flash-update {
    animation: flashUpdate 1.5s ease-out forwards;
}

/* Ensure alerts don't shrink */
#cheat-alert {
    flex-shrink: 0;
}

/* Neural Activity Stream Animation */
@keyframes stream-scan {
    0% { background-position: 0% 0%; }
    100% { background-position: 0% 100%; }
}
#thinking-content {
    background-image: linear-gradient(0deg, transparent 24%, rgba(168, 85, 247, 0.05) 25%, rgba(168, 85, 247, 0.05) 26%, transparent 27%, transparent 74%, rgba(168, 85, 247, 0.05) 75%, rgba(168, 85, 247, 0.05) 76%, transparent 77%, transparent);
    background-size: 50px 50px;
    /* animation: stream-scan 20s linear infinite; */ /* Disabled for readability, maybe enable on active thinking */
}
