/* ==============================================
   QUANTUM PORTFOLIO CSS - OUSSAMA ZERRAD
   ============================================== */

:root {
    --bg: #0a0b0f;
    --panel: #14161c;
    --ink: #e8e9ec;
    --muted: #9ca3af;
    --brand: #fbbf24;
    --accent: #60a5fa;
    --grid: #1f2937;
    --card: #111827;
    --good: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --surface: #1a1d24;
}

/* ==============================================
   BASE STYLES
   ============================================== */

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, Helvetica, sans-serif;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ==============================================
   BOOTSTRAP OVERRIDES
   ============================================== */

.container {
    max-width: 1200px;
}

.btn:focus,
.btn:active:focus {
    box-shadow: none;
}

/* ==============================================
   BACKGROUND EFFECTS
   ============================================== */

#bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    display: block;
}

.scan {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: -1;
    background: repeating-linear-gradient(
        0deg, 
        rgba(96,165,250,.02) 0 1px, 
        transparent 1px 3px
    ),
    repeating-linear-gradient(
        90deg, 
        rgba(251,191,36,.01) 0 1px, 
        transparent 1px 4px
    );
    mix-blend-mode: soft-light;
    opacity: 0.4;
}

.holodeck-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(96,165,250,.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(96,165,250,.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
    animation: gridShift 20s linear infinite;
}

@keyframes gridShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.cyberpunk-scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        transparent 50%,
        rgba(0,255,0,.02) 50%,
        rgba(0,255,0,.02) 51%,
        transparent 51%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1000;
    animation: scanlineScroll 0.1s linear infinite;
    opacity: 0;
    transition: opacity 0.5s ease;
}

@keyframes scanlineScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* ==============================================
   HEADER STYLES
   ============================================== */

header {
    position: relative;
    padding: 6rem 1.5rem 4rem;
    background: radial-gradient(ellipse at center top, rgba(251,191,36,.03) 0%, transparent 70%);
    cursor: crosshair;
}

h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(1.8rem, 3vw + 1rem, 3.2rem);
    letter-spacing: 0.02em;
    color: var(--brand);
    text-shadow: 0 0 30px rgba(251,191,36,.3), 0 2px 0 #000;
    animation: subtleGlow 4s ease-in-out infinite alternate;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

h1:hover {
    transform: scale(1.02);
    text-shadow: 0 0 40px rgba(251,191,36,.5), 0 2px 0 #000;
    filter: hue-rotate(15deg);
}

@keyframes subtleGlow {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.05); }
}

.tagline {
    color: var(--muted);
    max-width: 900px;
    margin: 0 auto 2.5rem;
    line-height: 1.7;
    font-size: 1.1rem;
    font-weight: 400;
}

/* ==============================================
   BUTTONS & CTAs
   ============================================== */

.cta {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 1.4rem;
    border: 1px solid var(--brand);
    color: #0a0b0f;
    background: var(--brand);
    border-radius: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 24px rgba(251,191,36,.15);
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 35px rgba(251,191,36,.25);
    background: linear-gradient(135deg, var(--brand), #fcd34d);
    color: #0a0b0f;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--brand);
    border-color: var(--grid);
    box-shadow: 0 4px 20px rgba(96,165,250,.08);
}

.btn-outline:hover {
    background: rgba(96,165,250,.1);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(96,165,250,.15);
    text-decoration: none;
}

/* CV Download Buttons */
.btn-cv {
    background: linear-gradient(135deg, var(--good), #059669);
    border-color: var(--good);
    color: white;
    box-shadow: 0 4px 20px rgba(16,185,129,.15);
}

.btn-cv:hover {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    border-color: #059669;
    box-shadow: 0 8px 30px rgba(16,185,129,.25);
    text-decoration: none;
}

.btn-cv.fr {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: #dc2626;
}

.btn-cv.fr:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    border-color: #b91c1c;
    box-shadow: 0 8px 30px rgba(220,38,38,.25);
}

/* ==============================================
   BADGES
   ============================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--grid);
    border-radius: 0.6rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(0,0,0,.1));
    backdrop-filter: blur(8px);
}

.badge.featured {
    border-color: rgba(251,191,36,.3);
    color: var(--brand);
    box-shadow: 0 0 20px rgba(251,191,36,.1);
}

/* ==============================================
   SECTION CARDS
   ============================================== */

.section-card {
    background: linear-gradient(135deg, rgba(255,255,255,.02), rgba(0,0,0,.1));
    border: 1px solid var(--grid);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,.1);
}

.section-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--grid);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(255,255,255,.03), rgba(0,0,0,.05));
}

.section-header h2 {
    margin: 0;
    font-family: 'Press Start 2P', monospace;
    font-size: 1.1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
}

.section-body {
    padding: 2rem;
}

/* ==============================================
   SKILLS
   ============================================== */

.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.chip {
    border: 1px solid var(--grid);
    background: var(--surface);
    padding: 0.6rem 0.9rem;
    border-radius: 0.6rem;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96,165,250,.1);
    border-color: rgba(96,165,250,.3);
}

.chip-primary {
    border-color: rgba(16,185,129,.4);
    box-shadow: inset 0 0 20px rgba(16,185,129,.08);
    background: linear-gradient(135deg, rgba(16,185,129,.05), var(--surface));
}

.chip-warning {
    border-color: rgba(245,158,11,.4);
    box-shadow: inset 0 0 20px rgba(245,158,11,.08);
    background: linear-gradient(135deg, rgba(245,158,11,.05), var(--surface));
}

/* ==============================================
   TIMELINE
   ============================================== */

.timeline {
    display: grid;
    gap: 1.5rem;
}

.timeline-item {
    border: 1px solid var(--grid);
    border-radius: 12px;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,.02), rgba(0,0,0,.05));
    transition: all 0.2s ease;
}

.timeline-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,.1);
    border-color: rgba(96,165,250,.3);
}

.timeline-item h3 {
    margin: 0.2rem 0 0.6rem;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

/* ==============================================
   PROJECT CARDS
   ============================================== */

.project-card {
    border: 1px solid var(--grid);
    border-radius: 14px;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--surface), var(--card));
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 260px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: rgba(96,165,250,.5);
    box-shadow: 0 20px 40px rgba(96,165,250,.1);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card.featured {
    border-color: rgba(251,191,36,.4);
    box-shadow: 0 8px 30px rgba(251,191,36,.08);
    background: linear-gradient(135deg, rgba(251,191,36,.02), var(--card));
}

.project-card.featured::before {
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
}

.project-card.featured:hover {
    border-color: rgba(251,191,36,.6);
    box-shadow: 0 20px 40px rgba(251,191,36,.15);
}

.project-card h3 {
    margin: 0.3rem 0 0.8rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
}

.project-card p {
    color: var(--muted);
    line-height: 1.6;
    flex-grow: 1;
    margin: 0;
    font-weight: 400;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tech {
    padding: 0.25rem 0.6rem;
    background: rgba(96,165,250,.1);
    border: 1px solid rgba(96,165,250,.2);
    border-radius: 0.4rem;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    transition: all 0.2s ease;
}

.tech:hover {
    background: rgba(96,165,250,.15);
    transform: translateY(-1px);
}

.project-meta {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: auto;
    padding-top: 1rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--grid);
    border-radius: 0.5rem;
    background: rgba(255,255,255,.02);
    font-weight: 500;
}

/* ==============================================
   3D REALITY WARP EFFECTS
   ============================================== */

.reality-warp {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.reality-warp:hover {
    transform: translateY(-6px) scale(1.02) rotateX(5deg) rotateY(2deg);
    box-shadow: 
        0 20px 40px rgba(96,165,250,.15),
        0 0 0 1px rgba(255,255,255,.1),
        inset 0 0 50px rgba(96,165,250,.05);
}

/* ==============================================
   CONTACT SECTION
   ============================================== */

.contact-card {
    background: linear-gradient(135deg, rgba(16,185,129,.05), rgba(0,0,0,.1));
    border: 1px solid rgba(16,185,129,.2);
    padding: 1.5rem;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16,185,129,.1);
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--ink);
    font-weight: 500;
}

.contact-item i {
    color: var(--good);
    width: 1.2rem;
}

.contact-item a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.contact-item a:hover {
    color: var(--brand);
    text-decoration: none;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.3);
    color: var(--good);
    font-weight: 600;
    font-size: 0.85rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--good);
    animation: pulse 2s infinite;
}

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

/* ==============================================
   CV DOWNLOAD SECTION
   ============================================== */

.cv-download-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--grid);
}

.cv-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.cv-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.cv-info h4 {
    color: var(--brand);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.cv-info p {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ==============================================
   QUANTUM EFFECTS
   ============================================== */

.quantum-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--accent);
    border-radius: 50%;
    pointer-events: none;
    animation: quantumFloat 8s infinite ease-in-out;
}

@keyframes quantumFloat {
    0%, 100% { 
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.3;
    }
    25% { 
        transform: translate3d(100px, -50px, 20px) scale(1.5);
        opacity: 0.8;
    }
    50% { 
        transform: translate3d(-50px, -100px, -10px) scale(0.8);
        opacity: 0.6;
    }
    75% { 
        transform: translate3d(-100px, 50px, 15px) scale(1.2);
        opacity: 0.9;
    }
}

.neural-connection {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    pointer-events: none;
    animation: neuralPulse 3s infinite ease-in-out;
    opacity: 0.3;
}

@keyframes neuralPulse {
    0%, 100% { 
        opacity: 0.1;
        transform: scaleX(0.5);
    }
    50% { 
        opacity: 0.8;
        transform: scaleX(1.2);
    }
}

.ai-consciousness {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    border: 2px solid var(--brand);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251,191,36,.1), transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: consciousnessField 4s ease-in-out infinite;
    z-index: 1000;
    cursor: pointer;
    color: var(--brand);
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.ai-consciousness:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(251,191,36,.5);
}

@keyframes consciousnessField {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 20px rgba(251,191,36,.3);
    }
    50% { 
        transform: scale(1.1) rotate(180deg);
        box-shadow: 0 0 40px rgba(251,191,36,.6);
    }
}

.portal {
    position: fixed;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, 
        var(--brand), var(--accent), var(--good), 
        var(--brand), var(--accent), var(--good));
    animation: portalSpin 3s linear infinite;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

@keyframes portalSpin {
    0% { transform: rotate(0deg) scale(0.5); }
    100% { transform: rotate(360deg) scale(0.5); }
}

.holo-effect {
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255,255,255,0.1) 50%, 
        transparent 70%);
    background-size: 200% 200%;
    animation: holoShine 3s ease-in-out infinite;
}

@keyframes holoShine {
    0%, 100% { background-position: -100% -100%; }
    50% { background-position: 100% 100%; }
}

/* Glitch effect */
.glitch {
    position: relative;
    animation: glitch 2s infinite;
}

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

.glitch::before {
    animation: glitch-1 0.5s infinite;
    color: #ff0000;
    z-index: -1;
}

.glitch::after {
    animation: glitch-2 0.5s infinite;
    color: #00ffff;
    z-index: -2;
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
}

@keyframes glitch-1 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(1px, 1px); }
    80% { transform: translate(1px, -1px); }
}

@keyframes glitch-2 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(1px, -1px); }
    40% { transform: translate(1px, 1px); }
    60% { transform: translate(-1px, -1px); }
    80% { transform: translate(-1px, 1px); }
}

.time-dilation {
    transition: all 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.time-dilation.active {
    animation: timeDilation 5s ease-in-out;
}

@keyframes timeDilation {
    0%, 100% { 
        filter: blur(0px) brightness(1);
        transform: scale(1);
    }
    50% { 
        filter: blur(2px) brightness(1.2);
        transform: scale(1.05);
    }
}

/* ==============================================
   PARTICLE TRAILS & LASER EFFECTS
   ============================================== */

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--brand);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFade 1s ease-out forwards;
}

@keyframes particleFade {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.3); }
}

/* ==============================================
   REVEAL ANIMATIONS
   ============================================== */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.in {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================================
   NEURAL NETWORK OVERLAY
   ============================================== */

#neuralNetwork {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* ==============================================
   FOOTER STYLES
   ============================================== */

footer {
    background: linear-gradient(135deg, rgba(255,255,255,.01), rgba(0,0,0,.05));
    border-top: 1px solid var(--grid);
    backdrop-filter: blur(10px);
}

footer .text-muted {
    color: var(--muted) !important;
}

footer i.text-warning {
    color: var(--brand) !important;
}

footer i.text-danger {
    color: var(--danger) !important;
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */

@media (max-width: 992px) {
    .section-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .section-header h2 {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 4rem 1rem 3rem;
    }
    
    .section-header {
        padding: 1rem 1.5rem;
    }
    
    .section-body {
        padding: 1.5rem;
    }
    
    .ai-consciousness {
        width: 60px;
        height: 60px;
        top: 15px;
        right: 15px;
        font-size: 1.2rem;
    }
    
    .project-card {
        min-height: auto;
    }
    
    .reality-warp:hover {
        transform: translateY(-3px) scale(1.01);
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .cta {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .cv-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .cv-buttons .cta {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    header {
        padding: 3rem 1rem 2rem;
    }
    
    h1 {
        font-size: clamp(1.4rem, 4vw, 2rem);
    }
    
    .section-header h2 {
        font-size: 0.9rem;
    }
    
    .section-body {
        padding: 1rem;
    }
    
    .skills {
        gap: 0.5rem;
    }
    
    .chip {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .tech-stack {
        gap: 0.3rem;
    }
    
    .tech {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .project-card {
        padding: 1rem;
        min-height: auto;
    }
    
    .project-card h3 {
        font-size: 1rem;
    }
    
    .timeline-item {
        padding: 1rem;
    }
    
    .timeline-item h3 {
        font-size: 1rem;
    }
    
    .cta {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .ai-consciousness {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    
    .portal {
        width: 150px;
        height: 150px;
    }
}

/* ==============================================
   PRINT STYLES
   ============================================== */

@media print {
    .ai-consciousness,
    .portal,
    #neuralNetwork,
    .cyberpunk-scanlines,
    .holodeck-grid,
    .scan,
    #bg {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .section-card {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* ==============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.cta:focus,
.chip:focus,
.project-card:focus,
.ai-consciousness:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg: #000000;
        --ink: #ffffff;
        --muted: #cccccc;
        --grid: #666666;
    }
}