/* --- Global Variables --- */
:root {
    --bg-dark: #0a0e1a;
    --card-bg: #111827;
    --formula-bg: #0d1117;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;

    --neon-cyan: #00f5ff;
    --electric-gold: #facc15;

    /* Module Accents */
    --mod1-color: #00f5ff;
    /* Cyan - Intro */
    --mod2-color: #facc15;
    /* Gold - DC */
    --mod3-color: #f97316;
    /* Orange - Transformer 1ph */
    --mod4-color: #a78bfa;
    /* Purple - Transformer 3ph */
    --mod5-color: #34d399;
    /* Green - Induction 3ph */
    --mod6-color: #fb7185;
    /* Rose - Induction 1ph */
    --mod7-color: #60a5fa;
    /* Blue - Alternator */
    --mod8-color: #f472b6;
    /* Pink - Sync Motor */
    --mod9-color: #fbbf24;
    /* Amber - Special Machines */

    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
}

.page-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar Navigation --- */
.sidebar {
    width: 260px;
    background: rgba(17, 24, 39, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    padding: 30px 20px;
    z-index: 100;
}

.sidebar-brand {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    margin-bottom: 30px;
    border-radius: 2px;
}

.progress-bar {
    height: 100%;
    background: var(--neon-cyan);
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s;
}

.nav-links {
    list-style: none;
}

.nav-section-title {
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    margin-top: 25px;
    font-weight: bold;
}

.mt-4 {
    margin-top: 1.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s;
    font-family: var(--font-heading);
}

.nav-links a .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 12px;
    opacity: 0.5;
    transition: opacity 0.3s, box-shadow 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-links a:hover .dot,
.nav-links a.active .dot {
    opacity: 1;
    box-shadow: 0 0 8px var(--accent);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
}

/* --- Hero Section --- */
.hero {
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: radial-gradient(circle at center, rgba(0, 245, 255, 0.05) 0%, transparent 60%);
    overflow: hidden;
}

.hero-content {
    text-align: center;
    z-index: 10;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 10px;
    letter-spacing: 4px;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.text-gradient {
    background: linear-gradient(90deg, var(--neon-cyan), var(--electric-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-btn {
    display: inline-block;
    padding: 12px 30px;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: var(--font-heading);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.2);
}

.hero-btn:hover {
    background: var(--neon-cyan);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.6);
}

.hero-bg-anim {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    opacity: 0.3;
    z-index: 0;
}

.hero-rotor {
    animation: rotateSlow 20s linear infinite;
}

@keyframes rotateSlow {
    100% {
        transform: rotate(360deg);
    }
}

/* --- Module Sections --- */
.module-section {
    padding: 80px 50px;
    max-width: 1400px;
    margin: 0 auto;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.module-header {
    margin-bottom: 50px;
}

.module-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: #fff;
    font-weight: 700;
}

.module-subtitle {
    color: var(--text-secondary);
    font-size: 1.8rem;
    font-weight: 400;
}

.module-line {
    height: 2px;
    width: 60px;
    background: var(--neon-cyan);
    margin-top: 15px;
    box-shadow: 0 0 10px var(--neon-cyan);
}

/* --- Card Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
}

.machine-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
}

.card-strip {
    height: 4px;
    width: 100%;
}

.card-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: #fff;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.formula-zone {
    background: var(--formula-bg);
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.formula {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.formula-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 15px;
    line-height: 1.5;
}

.anim-zone {
    height: 240px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

/* --- Specific Animations --- */
/* Faraday Conductor */
#conductor-group {
    animation: moveConductor 2s ease-in-out infinite alternate;
}

@keyframes moveConductor {
    0% {
        transform: translateY(-40px);
    }

    100% {
        transform: translateY(40px);
    }
}

/* Torque Armature */
#torque-armature {
    animation: rotateArmature 4s linear infinite;
    transform-origin: 200px 100px;
}

@keyframes rotateArmature {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Flowchart Tree Diagram --- */
.flowchart-zone {
    padding: 20px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    list-style-type: none;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}

.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1px solid var(--text-secondary);
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid var(--text-secondary);
}

.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

.tree li:only-child {
    padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

.tree li:last-child::before {
    border-right: 1px solid var(--text-secondary);
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 1px solid var(--text-secondary);
    width: 0;
    height: 20px;
}

.tree-node {
    border: 1px solid var(--text-secondary);
    padding: 8px 15px;
    text-decoration: none;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    display: inline-block;
    border-radius: 4px;
    transition: all 0.3s;
    background: var(--bg-dark);
}

.tree-node:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.4);
    color: var(--neon-cyan);
}

.tree-node.root {
    border-color: #fff;
    font-weight: bold;
}

.tree-node.dc-node {
    border-color: var(--mod2-color);
}

.tree-node.ac-node {
    border-color: var(--mod4-color);
}
/* --- Module 2: DC Machines --- */
/* Interactive SVG Cross Section */
.dc-part {
    transition: all 0.3s ease;
    cursor: pointer;
}

.dc-part:hover {
    fill: var(--mod2-color) !important;
    filter: drop-shadow(0 0 8px var(--mod2-color));
}

/* Calculator Inputs */
.calc-grid {
    margin-bottom: 10px;
}

.calc-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: 0.3s;
}

.calc-input:focus {
    border-color: var(--mod2-color);
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
}

.calc-input::placeholder {
    color: var(--text-secondary);
}

/* Commutator Rectifier Animation */
#dc-rectified {
    stroke-dasharray: 200;
    animation: rectify 2s linear infinite;
}

@keyframes rectify {
    from {
        stroke-dashoffset: 200;
    }

    to {
        stroke-dashoffset: 0;
    }
}

/* Winding Paths Animation */
#lap-paths path,
#wave-paths path {
    animation: flowDown 1s linear infinite;
}

@keyframes flowDown {
    from {
        stroke-dashoffset: 8;
    }

    to {
        stroke-dashoffset: 0;
    }
}
/* --- Module 3: 1-Phase Transformer --- */
#svg-transformer path,
#svg-transformer rect {
    transition: all 0.3s ease;
}

#t-flux-lines {
    animation: fluxPulse 2s ease-in-out infinite alternate;
}

@keyframes fluxPulse {
    0% {
        stroke-dashoffset: 20;
        opacity: 0.3;
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Real transformer heat glow */
.heat-glow {
    filter: drop-shadow(0 0 15px rgba(255, 82, 82, 0.8));
    animation: coreHeat 1s infinite alternate;
}

@keyframes coreHeat {
    from {
        filter: drop-shadow(0 0 5px rgba(255, 82, 82, 0.5));
        stroke: rgba(255, 82, 82, 0.5);
    }

    to {
        filter: drop-shadow(0 0 20px rgba(255, 82, 82, 1));
        stroke: rgba(255, 82, 82, 1);
    }
}
/* --- Module 4: 3-Phase Transformer --- */
.v-tab:hover {
    color: #fff !important;
}

.v-tab.active {
    color: #fff !important;
    background: rgba(167, 139, 250, 0.1) !important;
    border-bottom: 3px solid var(--mod4-color) !important;
}

#parallel-currents line {
    animation: flowRight 1s linear infinite;
}

@keyframes flowRight {
    from {
        stroke-dashoffset: 8;
        stroke-dasharray: 4 4;
    }

    to {
        stroke-dashoffset: 0;
        stroke-dasharray: 4 4;
    }
}
/* --- Module 5: 3-Phase Induction Motor --- */
@keyframes spinField {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

#sankey-glow {
    animation: flowRightSankey 2s linear infinite;
}

@keyframes flowRightSankey {
    from {
        stroke-dashoffset: 30;
    }

    to {
        stroke-dashoffset: 0;
    }
}

#ryb-waves path {
    animation: pulseWaves 2s ease-in-out infinite alternate;
}

@keyframes pulseWaves {
    0% {
        opacity: 0.5;
        stroke-width: 1;
    }

    100% {
        opacity: 1;
        stroke-width: 3;
    }
}
/* --- Module 6: 1-Phase Induction Motor --- */
@keyframes spinClockwise {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spinCounter {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

#drf-res {
    animation: pulseRes 3s ease-in-out infinite;
    transform-origin: 200px 100px;
}

@keyframes pulseRes {
    0% {
        transform: scaleY(1);
    }

    25% {
        transform: scaleY(0);
    }

    50% {
        transform: scaleY(-1);
    }

    75% {
        transform: scaleY(0);
    }

    100% {
        transform: scaleY(1);
    }
}

.s-tab:hover {
    color: #fff !important;
}

.s-tab.active {
    color: #fff !important;
    background: rgba(251, 113, 133, 0.1) !important;
    border-bottom: 3px solid var(--mod6-color) !important;
}
/* --- Module 7: Synchronous Machines --- */
.sync-lamp {
    position: relative;
}

.sync-lamp.glow {
    background: var(--electric-gold) !important;
    border-color: #fff !important;
    box-shadow: 0 0 20px rgba(250, 204, 21, 1) !important;
}
/* --- Module 8: Special Machines --- */
#bldc-flow1,
#bldc-flow2,
#arrow-bldc3 {
    animation: flowBldc 1s linear infinite;
}

@keyframes flowBldc {
    from {
        stroke-dashoffset: 6;
    }

    to {
        stroke-dashoffset: 0;
    }
}

.stepper-pole-active {
    stroke: var(--neon-cyan) !important;
    filter: drop-shadow(0 0 10px var(--neon-cyan));
}
/* --- Module 9: Synchronous Motors --- */
/* No specific additional animations needed, reusing spinClockwise and globals */