/* ========================================
   SECTION 6: SERVICE MATRIX (RADIAL SYSTEM)
   Design: Futuristic, Interactive, System-Oriented
   ======================================== */

.services-section {
    position: relative;
    width: 100%;
    min-height: auto;
    padding: 2rem 0;
    background: #050816;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    color: #fff;
}

/* Background Grid (Subtle) */
.services-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Header */
.services-header {
    text-align: center;
    margin-bottom: 4rem;
    z-index: 2;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease-out;
}

.services-section.visible .services-header {
    opacity: 1;
    transform: translateY(0);
}

.services-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.services-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    /* Changed to match branding */
    font-size: 1.1rem;
    color: var(--color-primary, #00d4ff);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.5rem;
}

.services-instruction {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    animation: pulseText 2s infinite ease-in-out;
}

@keyframes pulseText {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

/* MATRIX CONTAINER */
.matrix-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    /* Reduced to fit nicely */
    height: 600px;
    /* Sufficient height for radial layout */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* If a panel is open, shift matrix up slightly on desktop */
.matrix-container.has-active {
    transform: translateY(-50px);
}

/* CORE ENGINE */
.service-core {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 20, 40, 0.9) 0%, #050816 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.1);
    z-index: 10;
    transition: all 0.4s ease;
}

.core-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: absolute;
    border: 1px dashed rgba(0, 212, 255, 0.2);
    animation: spinCore 20s linear infinite;
}

.core-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    text-align: center;
    line-height: 1.2;
    font-weight: 600;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Core Interaction */
.service-core.pulse-active {
    box-shadow: 0 0 50px var(--active-color);
    border-color: var(--active-color);
}

/* ORBIT MODULES */
.service-module {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(16, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 5;

    /* Radial positioning var(--i) handled in CSS logic via JS or inline styles? 
       Using CSS transform based on angle would be cleanest. 
       Let's assume CSS transform: rotate(deg) translate(radius) rotate(-deg)
    */
    --angle: calc(360deg / 8 * var(--i));
    --radius: 260px;
    transform: rotate(var(--angle)) translate(var(--radius)) rotate(calc(var(--angle) * -1));
}

.service-module:hover {
    transform: rotate(var(--angle)) translate(var(--radius)) rotate(calc(var(--angle) * -1)) scale(1.1);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    z-index: 6;
}

/* Active State for Modules */
.service-module.active {
    transform: rotate(var(--angle)) translate(var(--radius)) rotate(calc(var(--angle) * -1)) scale(1.2);
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent);
    background: #0a0e27;
    z-index: 10;
}

/* Dim other modules when one is active */
.matrix-container.has-active .service-module:not(.active) {
    opacity: 0.3;
    pointer-events: none;
    /* Prevent clicking others during transition */
}

/* Module Content */
.module-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--accent);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

.module-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    max-width: 80px;
}

/* CONNECTION LINE (Dynamic) */
.connection-line {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 2px;
    background: var(--active-color, transparent);
    transform-origin: 0 50%;
    z-index: 1;
    width: 0;
    transition: width 0.4s ease, transform 0.4s ease;
    box-shadow: 0 0 10px var(--active-color);
}

/* DYNAMIC PANEL */
.dynamic-panel {
    position: fixed;
    /* Or absolute relative to section? Fixed works well for modal-like feel, absolute better for flow */
    /* Let's go with Absolute positioned at bottom of section for flow */
    position: absolute;
    bottom: 4rem;
    width: 90%;
    max-width: 900px;
    background: rgba(10, 14, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--active-color, #fff);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    padding: 2rem;
    z-index: 20;

    /* Animation States */
    opacity: 0;
    transform: translateY(50px);
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);

    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dynamic-panel.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
}

.panel-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    margin: 0;
}

.panel-desc {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
}

.panel-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}

.panel-close:hover {
    color: #fff;
}

/* Skill Grid in Panel */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.panel-card {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    color: #ffffff;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
}

.panel-card:hover {
    background: var(--active-color);
    transform: translateY(-2px);
    color: #050816;
    /* Dark text on bright active color */
    border-color: var(--active-color);
}

/* Stagger active cards */
.dynamic-panel.active .panel-card {
    animation: slideUpCard 0.4s forwards;
}

@keyframes slideUpCard {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spinCore {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .service-module {
        --radius: 200px;
        /* Compress orbit */
        width: 70px;
        height: 70px;
    }

    .module-icon {
        font-size: 1.2rem;
    }

    .matrix-container {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .services-section {
        height: auto;
        min-height: auto;
        padding-top: 0;
        padding-bottom: 2rem;
        /* Adjusted space */
    }

    .services-header {
        margin-bottom: 1rem;
        margin-top: 1rem;
    }

    .matrix-container {
        height: auto;
        padding: 0;
        flex-direction: column;
        margin-top: 0;
        transform: none !important;
        /* Disable shift */
    }

    /* Transform Radial to Grid/List on Mobile */
    .service-module {
        position: relative;
        transform: none !important;
        /* Disable radial logic */
        width: 100%;
        max-width: 300px;
        height: 60px;
        flex-direction: row;
        gap: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.03);
        justify-content: flex-start;
        padding-left: 1.5rem;
    }

    .service-core {
        display: none;
        /* Hide core on mobile */
    }

    .module-name {
        font-size: 0.9rem;
        text-align: left;
        max-width: none;
    }

    .dynamic-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        height: 60vh;
        overflow-y: auto;
    }
}